我有一个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;
}
当我点击导航栏时,它会打开,但不会滑到页面上。
您还需要将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;
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内容。它应该只在该元素的邮件声明中。此外,抽屉内容不需要溢出-y。也许正文溢出-x就足够了?:)我认为在一个元素上使用不同的宽松选项是不合适的。干杯:)。