화면의 왼쪽에서 숨겨진 패널이 있는데이 패널은 왼쪽에있는 '탭'클릭시 뷰로 슬라이드됩니다. 화면. 패널이 기존 페이지 콘텐츠의 맨 위로 슬라이드해야하며 탭을 이동해야합니다. 그래서 둘 다 CSS에 절대적으로 위치하고 있습니다. 모든 것은 잘 작동합니다. 그렇기 때문에 탭이 나올 때 (그리고 탭 컨테이너) 패널이 왼쪽으로 움직여야 패널의 오른쪽에 붙어있는 것처럼 보입니다. 수레를 사용하면 상대적으로 간단하지만 물론 이것은 기존 콘텐츠의 레이아웃에 영향을 미치므로 절대 위치 지정에 영향을줍니다. 나는 패널 컨테이너의 왼쪽 위치에 애니메이션을 적용 해 보았지만 (문서화 된 jquery 함수 참조), 작동시키지 못한다.jQuery - 슬라이딩 패널이 표시 될 때 절대적으로 위치한 div의 '왼쪽'위치 애니 메이팅
이것은 내가 변경 한 원래 코드의 예입니다. 버튼/탭을 어떻게 밀어 낼 수 있습니까?
http://www.iamkreative.co.uk/jquery/slideout_div.html
내 HTML
<div><!--sample page content-->
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
</p>
</div>
<div id="panel" class="height"> <!--the hidden panel -->
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore</p>
</div>
</div>
<!--if javascript is disabled use this link-->
<div id="tab-container" class="height">
<a href="#" onclick="return()">
<div id="tab"><!-- this will activate the panel. --></div>
</a>
</div>
내 jQuery를
$(document).ready(function(){
$("#panel, .content").hide(); //hides the panel and content from the user
$('#tab').toggle(function(){ //adding a toggle function to the #tab
$('#panel').stop().animate({width:"400px", opacity:0.8}, 100, //sliding the #panel to 400px
// THIS NEXT FUNCTION DOES NOT WORK -->
function() {
$('#tab-container').animate({left:"400px"} //400px to match the panel width
});
function() {
$('.content').fadeIn('slow'); //slides the content into view.
});
},
function(){ //when the #tab is next cliked
$('.content').fadeOut('slow', function() { //fade out the content
$('#panel').stop().animate({width:"0", opacity:0.1}, 500); //slide the #panel back to a width of 0
});
});
});
이는 CSS를
#panel {
position:absolute;
left:0px;
top:50px;
background-color:#999999;
height:500px;
display:none;/*hide the panel if Javascript is not running*/
}
#panel .content {
width:290px;
margin-left:30px;
}
#tab-container{
position:absolute;
top:20px;
width:50px;
height:620px;
background:#161616;
}
#tab {
width:50px;
height:150px;
margin-top:100px;
display:block;
cursor:pointer;
background:#DDD;
}
많은 감사