Dotted Border turns to solid if object is animated with jQuery
I have a simple setup: an image and then a paragraph with a bit of info that is hidden and then slides up over the image on mouse hover. If I try to apply a border-top that is dashed or dotted onto the paragraph it simply turns into a solid line. Is this a known issue with a fix? I even tried adding the dotted border through jQuery and it still comes out as a solid line.
HTML:
<div class="wrap">
<img src="images/fillertxt.jpg" alt="image" />
<img src="images/filler.jpg" class="front" alt="image" />
<p class="info">
This is a short description with a bit of text.
</p>
</div>
CSS:
.wrap .info {
width:204px;
height:50px;
background:url(images/infobg.jpg) repeat-x #8d9c0c;
color:#f7f5ef;
padding:3px;
position:absolute;
top:142px;
left:0;
border-top:3px dotted #8d9c0c;
}
JS:
$(document).ready(function(){
$("p.info").css("border-top","3px dotted #8d9c0c");
$(function(){
bindTypeOne();
$("input[type=radio]").click(function(){开发者_如何学JAVA
if ($(this).attr("rel") == "type1"){
bindTypeOne();
} else if ($(this).attr("rel") == "type2"){
bindTypeTwo();
}
});
});
function bindTypeOne() {
$("div.wrap").hover(function(){
$(this).children("p.info").stop();
$(this).children(".front").stop().animate({"top":"141px"}, 400);
},function(){
$(this).children("p.info").stop();
$(this).children(".front").stop().animate({"top":"0"}, 700);
});
};
function bindTypeTwo() {
$("div.wrap").hover(function(){
$(this).children(".front").stop();
$(this).children("p.info").stop().animate({"top":"80px","border-top":"3px dotted #8d9c0c"}, 400);
},function(){
$(this).children(".front").stop();
$(this).children("p.info").stop().animate({"top":"142px"}, 700);
});
};
});
I don't think "border-top" will work with animation. I know that, to set border width in animation, you have to use borderWidth
not border-width
. So Please try using likewise. Hope it will help :)
Can't reproduce what you describe (using Opera).
Check this simple demopage http://jsbin.com/ofoya
Please provide a working sample which reproduces your problem. And include information which browser you use.
Btw. are you aware that you set the background-color
and the border-color
to the same color code? Try changing border-top:3px dotted #8d9c0c;
to e.g. border-top:3px dotted #FF0066;
border-top does work if you use the jquery ui, but you need to change it to "borderTop". Sadly I have found that you have to define each border side
$(this).stop().animate({
backgroundColor: "#000",
borderRightColor: "#09c",
borderLeftColor: "#09c",
borderTopColor: "#09c",
borderBottomColor: "#09c"
}, "slow");
精彩评论