试图做一个按钮悬停效果我偶然发现了IE上的这个奇怪的错误。IE 11上的伪元素转换忽略填充
即使在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之间的巨大差异。你可以分享另一个演示,尽可能少的代码,强调这个问题? – Sampson
当您在IE11中查看框时,它看起来像正在动画的3px边框的一部分在框的中间短暂显示,然后移动到框的中间。它发生得很快。我假设这是什么OP是在谈论 – crazymatt
确实提供了一个行高而不是顶部和底部填充帮助? –