IE会导致css宽度动画反转

时间:2014-05-19 01:48:25

标签: html css css3 css-animations

相关部分:

#inline-navigation ul {
    display: table;
    text-transform: uppercase;
    text-align: center;
    list-style-type: none;
    margin: 0 auto;
    padding: 24px 0px;
}

#inline-navigation ul li {
    display: table-cell;
}

#inline-navigation ul li a {
    text-decoration: none;
    color: #777;
    padding: 0 4px;
    font-family: Monaco, Consolas, "Lucida Console", monospace;
    font-size: 15px;
    transition: 0.3s;
    height: 20px;
    line-height: 20px;
    margin: 0 4px;
    position: relative;
}

#inline-navigation ul li a:after,
#inline-navigation ul li a:before {
    content: '';
    border-bottom: 1px solid #ff6600;
    box-shadow: 0 2px 2px -2px #777;
    display: block;
    position: absolute;
    transition: 0.1s;
    width: 0;
}

#inline-navigation ul li:nth-child(1) a:before,
#inline-navigation ul li:nth-child(2) a:before {
    right: 0;
    top: -4px;
}

#inline-navigation ul li:nth-child(1) a:after,
#inline-navigation ul li:nth-child(2) a:after {
    bottom: -4px;
    left: 0;
}

#inline-navigation ul li:nth-child(3) a:before,
#inline-navigation ul li:nth-child(4) a:before {
    left: 0;
    top: -4px;
}

#inline-navigation ul li:nth-child(3) a:after,
#inline-navigation ul li:nth-child(4) a:after {
    bottom: -4px;
    right: 0;
}

#inline-navigation ul li a:hover {
    color: #ff6600;
}

#inline-navigation ul li a:hover:before,
#inline-navigation ul li a:hover:after {
    width: 75%;
}

在Internet Explorer 11中,动画会产生极其明显的边框闪烁,:after:before元素上的边框似乎会转义父元素(?)。我认为这是因为与其他浏览器相比,动画是反向播放的。

小提琴; http://jsfiddle.net/NfE87/

适用于Chrome和Firefox。想法?

1 个答案:

答案 0 :(得分:1)

默认情况下,

<a>元素是内联的,您的样式会在:before:after样式中阻止它们。看起来IE在使用默认内联和块样式之间切换锚点时遇到问题。不确定那个问题究竟是什么,但是......

如果你在样式表中制作锚点,那么&#34;切换&#34;没有发生,它解决了问题,所以只需添加

a{display:block;}到样式表的底部。请记住,将锚点更改为块元素可能会影响布局,因此请进行相应调整。