Reputation: 13250
I am trying to work with a simple div(leftContainer) and would like to make it slide from left to its total width on page load and not with a button click.
Here is my code:
<div class="leftContainer ">
<div class="header">Header</div>
<div class="mainbody">
<p>Body</p>
</div>
DEMO
Upvotes: 3
Views: 11027
Reputation: 20471
$("div.leftContainer")
.css("margin-left",-$(this).width())
.animate({
marginLeft:0
}, 700);
Upvotes: 3
Reputation: 7153
Try the following:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("div.leftContainer").animate({width:100%}, "slow");
});
</script>
If you're looking for a fixed width instead of 100%, change that as well. Good luck! If it doesn't work, please be more clear on what you want done, and I'll try to assist you.
Upvotes: 1
Reputation: 3246
made a simple example, dont know what you are trying to do.
use animate to do whatever you want animate();
$(".leftContainer").animate({
left: "50%"
});
Upvotes: 1
Reputation: 39872
You can animate the width using jQuery.
$('.leftContainer').animate({ width: '100%'});
Upvotes: 3