【问题标题】:Animation not rendering well in Microsoft EdgeMicrosoft Edge 中的动画渲染效果不佳
【发布时间】:2018-11-21 09:04:10
【问题描述】:

我正在使用卡片作为新闻块。

悬停卡片时,会从下到上(滑动)显示叠加层

在 IE 中查看时,在 Firefox 和 Chrome 浏览器上一切正常,动画呈现非常糟糕,也没有滑动动画

谁能指导我,我会在这里附上我的代码。

欢迎任何改进、建议或替代解决方案。

ps:我目前使用的是 Microsoft Edge 42.17134.1.0

.card_container{ 
        position:relative; 
        width:280px; 
        margin:auto; 
        background:rgba(0,0,0,0.2); 
        height:450px; overflow:hidden;
      }
.card_text{
       position:absolute; 
       color:#fff; 
       height:100%; 
       width:100%; 
       top:0; 
       left:0;
     }
.card_text .pre_state {
       position:absolute; 
       top:calc(100% - 30%); 
       width:100%; 
       padding:30px 15px 25px; 
       height:100%; 
       transform:translate(0%, -30px);
}
.card_text h5{
       font:14px/25px 'Graphik-Regular'; 
       padding-bottom:10px;
 }
.card_text h2{
       font:20px/22px 'Graphik-Medium';
 }
.card_text a.hidn{
       position:absolute; 
       bottom:15%; 
       font:14px/22px 'Graphik-Medium'; 
       color:#fff; 
       display:none;
 }
.card_container:hover .card_text .pre_state{
       top:0; 
       background-color:rgba(51,154,205,0.7); 
       transition:all .5s ease-out, all 0.5s ease-in; 
       transform:none;
}
.card_container:hover .card_text a.hidn{
      display:block;
}
<div class="card_container">
  <div class="card_text">
    <div class="pre_state">
      <h5>20 Oktober 2018</h5>
				<h2>Vestibulum facilisis, tortor atrutrum cursus.</h2>
						<a href="#" class="hidn">Read more &gt; </a>
    </div>	
  </div>
</div>

【问题讨论】:

  • 看起来 calc 仅在 IE 9 中得到部分支持 - caniuse.com/#search=calc
  • @Mohammad 没有解决我的问题
  • IE 9 不支持transition,正如您在caniuse.com/#feat=css-transitions 中看到的那样
  • 我不知道它的Microsoft Edge 42.17134.1.0是什么版本的IE
  • 首先你说我目前使用的是IE 9

标签: javascript html css microsoft-edge


【解决方案1】:

正如您明确指出的那样,滑动动画在 IE 中不起作用只是因为 IE 不支持/部分支持 calc() 属性

顺便说一句..你为什么要给top:calc(100% - 30%);你可以直接提到top:70%;

试试这个

.card_container{ 
        position:relative; 
        width:280px; 
        margin:auto; 
        background:rgba(0,0,0,0.2); 
        height:450px; overflow:hidden;
      }
.card_text{
       position:absolute; 
       color:#fff; 
       height:100%; 
       width:100%; 
       top:0; 
       left:0;
     }
.card_text .pre_state {
       position:absolute; 
       /*top:calc(100% - 30%); */
       top: 70%;
       width:100%; 
       padding:30px 15px 25px; 
       height:100%; 
       transform:translate(0%, -30px);
}
.card_text h5{
       font:14px/25px 'Graphik-Regular'; 
       padding-bottom:10px;
 }
.card_text h2{
       font:20px/22px 'Graphik-Medium';
 }
.card_text a.hidn{
       position:absolute; 
       bottom:15%; 
       font:14px/22px 'Graphik-Medium'; 
       color:#fff; 
       display:none;
 }
.card_container:hover .card_text .pre_state{
       top:0; 
       background-color:rgba(51,154,205,0.7); 
       transition:all .5s ease-out, all 0.5s ease-in; 
       transform:none;
}
.card_container:hover .card_text a.hidn{
      display:block;
}
<div class="card_container">
  <div class="card_text">
    <div class="pre_state">
      <h5>20 Oktober 2018</h5>
				<h2>Vestibulum facilisis, tortor atrutrum cursus.</h2>
						<a href="#" class="hidn">Read more &gt; </a>
    </div>	
  </div>
</div>

参考资料: https://css-tricks.com/forums/topic/calc-not-always-working-in-ie/

浏览器支持:https://caniuse.com/#feat=calc

【讨论】:

  • 谢谢你,我正在挠头来解决这个滑动问题,也谢谢你的参考
猜你喜欢
  • 2012-07-08
  • 1970-01-01
  • 2016-01-16
  • 2019-07-06
  • 2018-05-30
  • 2014-12-10
  • 2017-08-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多