本文介绍了.animate不透明度:show-需要display:block;而不是display:inline;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在链接悬停上显示某个元素(em).
I want to show a certain element (em) on link hover.
我想出了这一点(通过在线教程).
I came up with this (through online tutorials).
<script type="text/javascript">
$(window).load(function() {
$("ul.slidebtns li a").hover(function() {
$(this).next("em").animate({opacity: "show"}, "fast");
}, function() {
$(this).next("em").animate({opacity: "hide"}, "fast");
});
});
</script>
但是.animate({opacity:"show"}为我提供display:inline而不是display:block-正如我读过的display:block应该是默认行为...那是怎么回事?
But .animate({opacity: "show"} gives me display:inline instead of display:block - as I've read around display:block should be a default behavior... so what is wrong?
推荐答案
好吧,您可以在.css
文件或jQuery代码中给它CSS:
Well you can give it css in your .css
file or in your jQuery code:
$(window).load(function() {
$("ul.slidebtns li a").hover(function() {
$(this).next("em").css({ display: "block", opacity: 0 }).animate({ opacity: "show" }, "fast");
}, function() {
$(this).next("em").animate({opacity: "hide"}, "fast");
});
});
这篇关于.animate不透明度:show-需要display:block;而不是display:inline;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!