I'm having an issue with vertically centering content within a slider, I have managed to get it working on resize but my javascript doesn't work on page load for some reason.
I get the feeling this might be due to the fact the content is positioned absolute and maybe doesnt have a height value on load? But thats just a wild guess.
Here is the example: DEMO
<div id="slides">
<ul class="slides-container">
<li>
<div class="slider_content">
<h1>Some Text</h1>
<p>Quisque ultrices, libero eget aliquet consequat, sapien leo sollicitudin ligula, fermentum luctus enim libero a neque. Nam dapibus, lectus nec condimentum volutpat, diam nisl cursus odio, vitae luctus libero augue at dolor. Nullam ut quam ut augue facilisis ultrices eget non risus.</p>
</div>
<img src="http://nicinabox.com/superslides/images/building.jpg" width="1024" height="682" alt=""/>
</li>
</ul>
</div>
// VERTICALLY ALIGNS THE SLIDER CONTENT ON LOAD (NOT WORKING)
$(window).load(function() {
$('.slider_content').each(function(event) {
$(this).css({"margin-top": - ( $(this).outerHeight()/2 ) });
});
});
// VERTICALLY ALIGNS THE SLIDER CONTENT ON RESIZE (WORKING)
$(document).ready(function() {
$(window).resize(function() {
$('.slider_content').each(function(event) {
$(this).css({"margin-top": - ( $(this).outerHeight()/2 ) });
});
});
});
Thanks for any help!