当复选框被点击时,
nav
的 margin:left
应该增加并进入屏幕。再次点击时,它应该减少并离开屏幕。但我的代码没有按照这个方式工作。我的代码有什么问题?
Html
<input type="checkbox" id="res-nav">
<label for="res-nav"><i class="fa fa-reorder" style="font-size:36px"></i></label>
样式
body label {
position: fixed;
display: block;
margin-left:-100px;
margin-top: -115px;
z-index:99;
}
nav{
margin-left:-130px;
transition: all 0.5s;
-moz-transition: all 0.5s;
-ms-transition: all 0.5s;
-o-transition: all 0.5s;
-webkit-transition: all 0.5s;
}
#res-nav:checked ~ nav {
margin-left:50px;
}
<nav>
元素确切的位置在哪里? - connexobody
标签中的nav
。你问了吗? - Ahmet Yılmaz