简体   繁体   English

firefox CSS转换错误

[英]firefox CSS transition bug

I wrote some CSS to cause a sidebar to do a slide transition from off the page to visible when you mouse over the side of the page. 我编写了一些CSS,以使边栏在您将鼠标悬停在页面的一侧时,可以从页面外滑动到可见。 The CSS is simple and involves adding/removing a class that controls the left: position of the sidebar. CSS很简单,涉及添加/删除控制侧栏的left:位置的类。

#sidebarInner{
  height:100%;
  width:50px;
  background-color:blue;
  position: fixed;
  -moz-transition: left .2s linear;
  -webkit-transition: left .2s linear;
  -o-transition: left .2s linear;
  transition: left .2s linear;
  z-index:2;
}
.slideLeft {
  left: -100px;
}

Try the following demo on a webkit browser and on Firefox: http://jsfiddle.net/MmFnY/7/ 在Webkit浏览器和Firefox上尝试以下演示: http : //jsfiddle.net/MmFnY/7/

You'll notice on webkit, the blue colored div has the 0.2s slide left transition but on Firefox it does not. 您会在webkit上注意到,蓝色的div向左滑动了0.2秒,但在Firefox上却没有。 Does anyone know whats wrong with the CSS above? 有人知道上面的CSS有什么问题吗?

In order for the transition to work you need to provide it with a default left value. 为了使过渡正常工作,您需要为其提供默认的左值。 Easiest way to do this is probably to give it another class for when it's inside such as: 最简单的方法可能是在内部添加另一个类,例如:

.slideRight{
    left: 0px;
}

http://jsfiddle.net/MmFnY/19/ http://jsfiddle.net/MmFnY/19/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM