我試圖與圖像移動的DIV框從左向右,如何移動DIV水平
我嘗試另一個腳本:http://jsfiddle.net/bala2024/MzHmN/
下面是HTML代碼
<!DOCTYPE html>
<html>
<head></head>
<body style>
<div id="slideleft" class="slide">
<button>slide it</button>
<div class="inner">Slide to the left</div>
<div style="width:50px; height:50px">
<img src="sceen.jpg">
</div>
</div>
</body>
</html>
CSS
.slide {
position: relative;
background-color: gray;
height: 100px;
width: 500px;
overflow: hidden;
}
.slide .inner {
position: absolute;
left: -500px;
bottom: 0;
background-color:#e3e3e3;
height: 30px;
width: 500px;
}
JS
$(document).ready(function() {
$('#slideleft button').click(function() {
var $lefty = $(this).next();
$lefty.animate({
left: parseInt($lefty.css('left'), 10) == 0 ? -$lefty.outerWidth() : 0
});
});
});
用CSS?有相對和絕對的定位..你也可以使用填充/邊距來操作元素。 –
你什麼時候想從左向右移動div盒?點擊按鈕?和你指的是哪一個div?需要一些時間來解釋清楚。 –
css code here: – user1799052