我有一个div positioned: absolute;
和left: -250px;
。单击打开的导航栏按钮时,我希望该项目滑到页面上。我不确定我错过了什么,
.drawer .drawer-content {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: -280px;
overflow-y: scroll;
-webkit-transition: left 5s ease;
-moz-transition: left 1s linear;
-o-transition: left 1s linear;
transition: left 5s ease;
}
.open > .drawer .drawer-content {
left: 0;
webkit-transition: left 5s ease;
-moz-transition: left 1s linear;
-o-transition: left 1s linear;
transition: left 5s ease;
}
当我点击导航栏时,它会打开,但不会滑到页面上。
答案 0 :(得分:1)
您还需要将transition
属性应用于.open > .drawer .drawer-content
代码。
.open > .drawer .drawer-content {
transition-property: left;
transition-duration: 1s;
transition-timing-function: linear;
left: 0;
}
您应该考虑优化转换代码,使其更像以下内容:
transition: [transition-property] [transition-duration] [transition-timing-function] [transition-delay];
所以在你的情况下它会是:
transition: left 1s linear;
最后,不要忘记使用浏览器前缀:
-webkit-transition: left 1s linear;
-moz-transition: left 1s linear;
-o-transition: left 1s linear;
transition: left 1s linear;
答案 1 :(得分:0)
Css看起来应该更像这样:
.drawer {
position: relative;
width: 100%;
height: 100%;
}
.drawer .drawer-content {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: -280px;
transition: all ease-in-out 3s;
-moz-transition: all ease-in-out 3s;
-webkit-transition: all ease-in-out 3s;
}
.open > .drawer .drawer-content {
left: 0;
}
您无需设置转换为.open ... .drawer-content。它应该只在这个元素的邮件声明中。 你也不需要为.drawer-content溢出-y。也许溢出-x身体就足够了?:) 我不认为在一个元素上使用不同的缓动选项是正确的。 干杯:)。