Here is an example, how to make a div always center align using jquery. You can do this using css but this method will work with positions (absolute, fixed etc) and it is also compatible with internet explorer.
<script>
$(document).ready(function(){
var windowWidth = $(window).width();
var divWidth = $("div").width();
$("div").css({"margin-left":(windowWidth-divWidth)/2});
});
</script>
0 Comment(s)