I’ve got a div that is hidden on page load and stretches to 100% width via jQuery. Animation is great, but the content fluidly adjust until it’s container (which is within the stretchy div) reaches it’s full set width.
Previously the content didn’t shift and I can’t tell what changed that behavior after so many edits to the code! How can I fix the content from moving; showing as much as the resizing div allows without any movement? The specific problems are:
-#show_contact anchor drops below its two sisters until it has room to be on the same line
-#collections div’s margin:0 auto is affected by #show_contact’s short visit
Thanks!
P.S.- here’s what it looked like before/what I want it to look like now: http://jsfiddle.net/ZP86m/
HTML:
<div id="slider">
<div id="trigger">
<img class="arrow_small" src="images/left_small.png" alt="slide menu out" />
</div>
<div class="trans" id="overlay"></div>
<div id="content">
<div id="main_nav">
<div id="nav_links">
<div class="nav_link"><h3><a class="showlink" id="show_campaigns" title="Campaigns">CAMPAIGNS</a></h3></div>
<div class="nav_link"><h3><a class="showlink" id="show_collections" title="Collections">COLLECTIONS</a></h3></div>
<div class="nav_link"><h3><a class="showlink" id="show_contact" title="Contact">CONTACT</a></h3></div>
</div>
<div id="nav_container">
<div class="nav" id="campaigns">
<p>CAMPAIGNS!</p>
</div>
<div class="nav current" id="collections">
<p>COLLECTIONS!</p>
</div>
<div class="nav" id="contact">
<p>CONTACT!</p>
</div>
</div>
</div>
</div>
</div>
CSS:
#slider {
width:100%;
height:100%;
top:0;
right:0;
float:right;
position:absolute;
}
#overlay {
width:100%;
height:100%;
position:absolute;
}
#content {
width:100%;
height:100%;
position:relative;
z-index:1;
}
#main_nav {
width:684px;
height:100%;
margin:0 auto;
padding:0px 30px 0px 30px;
}
#nav_links {
width:100%;
height:40px;
}
.nav_link {
width:33%;
float:left;
margin:20px 0px 0px 0px;
position:relative;
text-align:center;
}
.nav{
width:208px;
height:100%;
padding:20px 10px 20px 10px;
margin:0 auto;
text-align:center;
}
Javascript:
// Slide out menu
$('#slider')[0].style.width = '30px';
$(function() {
$('#trigger').toggle(function (){
$('#slider').animate({'width':'100%'}, 1500);
$('.arrow_small').attr('src','images/right_small.png');
}, function() {
$('#slider').animate({'width':'30px'}, 1500);
$('.arrow_small').attr('src','images/left_small.png');
});
});
main_nav’s padding had to match the width of the animation of slider