【发布时间】:2015-06-12 22:42:17
【问题描述】:
尝试制作按钮悬停效果时,我在 IE 上偶然发现了这个奇怪的错误。
即使在 IE11 上也会发生这种情况。
当您将鼠标悬停在按钮上时,伪元素会“跳跃”它们的过渡。 如果您删除填充,它会停止!
我整个下午都在努力解决这个问题,但我似乎找不到问题。
这是演示:http://codepen.io/anon/pen/rVwRKL
HTML
<a href="http://##" title="yeah">Live Button</a>
CSS
body
{
padding: 5em;
margin: 0;
}
a{
padding: 1em 1em;
margin: 0;
box-shadow: inset 0px 0px 0px 3px blue;
position: relative;
box-sizing: border-box;
display: inline-block;
}
a::before,
a::after
{
transition: width 0.4s ease, height 0.4s ease 0.4s, opacity 0.4s ease;
content: " ";
box-sizing: border-box;
width: 100%;
height: 100%;
display: block;
position: absolute;
border: solid 3px green;
display: inline-block;
}
a::after
{
right: 0;
bottom: 0;
border-right-color: transparent;
border-top-color: transparent;
}
a::before
{
left: 0;
top: 0;
border-left-color: transparent;
border-bottom-color: transparent;
}
a:hover::before,
a:hover::after
{
transition-delay: 0.4s, 0s, 0.7s;
width: 0;
height: 0;
opacity: 0;
}
谢谢!
【问题讨论】:
-
我没有看到 IE 11 和 Chrome 之间有很大的区别。您能否分享另一个演示,使用尽可能少的代码,强调这个问题?
-
当您在 IE11 中查看该框时,看起来正在动画的 3px 边框的一部分在框的中间短暂显示,然后移到框的外部。它发生得很快。我假设这就是 OP 所说的
-
是否给 a 行高而不是顶部和底部填充有帮助?
-
大家好,感谢 cmets。 @JonathanSampson 在 chrome 上的动画很流畅,在 IE 上,只要你悬停它就会跳转到按钮的中间。
-
嘿@CarolMcKay,行高不起作用。我对这个很迷茫。
标签: css internet-explorer debugging transition