moving div horizontally?
sliding div using javascript
i have three div with some content开发者_运维百科. i need the div to be moved one after another . moving div horizontally
any idea..
You shall have to set position=absolute and then set x and y for the div. You can change their x and y inside a javascript. There are plenty of available scripts for sliding.
Could be done like this:
// Moving the element to the 200 x 200 coordinate relative to
// the parent element, WITHOUT JQUERY
var elementStyles = document.getElementById("someDiv").style;
elementStyles.position = "absolute";
elementStyles.top = 200 + "px";
elementStyles.left = 200 + "px";
// Moving the element to the 200 x 200 coordinate relative to
// the parent element, WITH JQUERY
$("#someDiv").animate({
top: 200 + "px",
left: 200 + "px"
});
// If the position should be changed relative to the current position,
// add a `"+=" +` in front of `200` in the jQuery script, like this:
left: "+=" + 200 + "px"
You could use jQuery and the slideDown()
and slideUp()
functions. See http://api.jquery.com/category/effects/sliding/
精彩评论