我正在尝试创建一个侧栏,当用户单击某个按钮时它将滑入并显示内容。在不移动相邻内容的情况下滑动div
我遇到的问题是当它点击标题上的所有内容时,正文和页脚正在移动。
我想滑动div来点击时无需移动它的菜单和内容上滑动,创造一个覆盖
检查小提琴http://jsfiddle.net/livewirerules/tsmpraym/9/
下面是我到目前为止已经试过
jQuery(document).ready(function($) {
$("#side").click(function() {
$('#slidable').animate({
width: 'toggle'
});
});
})
#menu {
background-color: green;
height: 100px;
}
#footer {
background-color: blue;
height: 100px;
}
#content {
background-color: red;
height: 400px;
}
#side {
float: left;
width: 50px;
height: 50px;
background: #BBB;
}
.hide {
display: none;
}
#slidable {
float: left;
height: 200px;
background: #888;
width: 200px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js"></script>
<div id="slidable" class="hide">Foobar</div>
<div id="side">+</div>
<div id="menu">
the menu
</div>
<div id="content">
content
</div>
<div id="footer">
the footer
</div>
为此,您可以设置绝对的滑动元件的位置。看看这里:http://jsfiddle.net/tsmpraym/12/ –