【发布时间】:2017-10-06 09:54:11
【问题描述】:
如何将.css method 添加到此 jQuery 中,以便将内容推离画布,而不是将侧边栏覆盖在内容上。
jQuery(function( $ ){
$('.button').click(function() {
$('.sidebar').animate({
width: 'toggle'},
'slow'
);
});
});
.sidebar {
width: 350px;
height: 100%;
position: fixed;
background-color: #f5f5f5;
display: none;
padding: 20px;
}
.content {
width: 700px;
float: right;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="button">Toggle</button>
<div class="sidebar">
This is the slide out sidebar content
</div>
<div class="content">
This is the main content area. This is the main content area. This is the main content area. This is the main content area. This is the main content area. This is the main content area.
</div>
我在想这样的事情可能会奏效,但不知道如何将它包含在 jQuery 中现有的 .animate method 中:
$('.content').css('marginLeft') = '350px';
【问题讨论】:
标签: jquery css jquery-animate