如果对象使用 jQuery 进行动画处理,点状边框将变为实线
我有一个简单的设置:一张图像,然后是一个带有一些隐藏信息的段落,然后在鼠标悬停时在图像上向上滑动。如果我尝试将虚线或点线的顶部边框应用到段落上,它只会变成实线。这是一个已修复的已知问题吗?我什至尝试通过 jQuery 添加虚线边框,但它仍然显示为实线。
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(){
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 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(){
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);
});
};
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为“border-top”不适用于动画。我知道,要在动画中设置边框宽度,您必须使用
borderWidth
而不是border-width
。所以请尝试同样使用。希望它会有所帮助:)I don't think "border-top" will work with animation. I know that, to set border width in animation, you have to use
borderWidth
notborder-width
. So Please try using likewise. Hope it will help :)无法重现您所描述的内容(使用 Opera)。
检查这个简单的演示页面http://jsbin.com/ofoya
请提供一个可以重现您的问题的工作示例。并包含您使用的浏览器的信息。
顺便提一句。您是否知道您将
background-color
和border-color
设置为相同的颜色代码?尝试将border-top:3px dotted #8d9c0c;
更改为border-top:3px dotted #FF0066;
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 theborder-color
to the same color code? Try changingborder-top:3px dotted #8d9c0c;
to e.g.border-top:3px dotted #FF0066;
如果您使用 jquery ui,border-top 确实可以工作,但您需要将其更改为“borderTop”。遗憾的是我发现你必须定义每个边界边
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