问题
Please see this fiddle http://jsfiddle.net/MKwwH/
I want the link images-link
to slide toggle right to left?
$(document).ready(function() {
$('.hidden').hide()
});
$('.soundDiv-link').click(function() {
$('#soundDiv').slideToggle("slow")
});
$('.videoDiv-link').click(function() {
$('#videoDiv').next().animate({width: 'toggle'}, "slow")
});
$('.imagesDiv-link').click(function() {
$('#imagesDiv').animate({width: 'toggle'}, "slow")
});
回答1:
The issue is that you have left and right set. Just set right to 0 and it will work.
http://jsfiddle.net/MKwwH/4/
#imagesDiv {
background-color: yellow;
width: 100%;
height: 100%;
position: fixed;
top: 0px;
bottom: 0px;
right: 0px;
overflow: hidden;
display: none;
}
回答2:
You where almost right :
$('#videoDiv').next().animate({width: '100%'}, "slow");
But first you need to put width to a 0px;
See this working jsFiddle example.
回答3:
USE THIS FOR RIGHT TO LEFT SLIDING :
<div class="nav ">
<ul>
<li><a href="#">HOME</a></li>
<li><a href="#">ABOUT</a></li>
<li><a href="#">SERVICES</a></li>
<li><a href="#">CONTACT</a></li>
</ul>
</div>
CSS:
.nav{
position: fixed;
right:0;
top: 70px;
width: 250px;
height: calc(100vh - 70px);
background-color: #333;
transform: translateX(100%);
transition: transform 0.3s ease-in-out;
}
.nav-view{
transform: translateX(0);
}
JS:
$(document).ready(function(){
$('a#click-a').click(function(){
$('.nav').toggleClass('nav-view');
});
});
SOURCE FILES: WATCH TUTORIAL AND DOWNLOAD SOURCE
来源:https://stackoverflow.com/questions/19316805/how-to-slide-toggle-a-div-right-to-left