Use top and left.
#wrapper {
left: 50%;
position: absolute;
margin-left: -223px /* half of width*/
}
Then animate div using:
$('button[name="whattoput"]').click(function () {
$('div').animate({
left: "323px" // target position + left margin
});
});
check this please make position of #wrapper to relative
.hidestuff {
//display: none;
}
#wrapper {
margin-left:auto;
margin-right:auto;
width: 445px;
position:relative;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.