I'm new to Jquery. I want to know how can we use margin: 0 auto; CSS code in jquery scripting. Could anyone please help me out? Here's the code:
<style>
#fixed-bar {
padding: 0;
background-color: black;
z-index: 100;
}
</style>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
<script>
$(function () {
$("#fixed-bar")
.css({
"position": "fixed",
"width": "960px",
"margin": "0 auto",
"top": "0px",
})
.hide();
$(window).scroll(function () {
if ($(this).scrollTop() > 400) {
$('#fixed-bar').fadeIn(200);
} else {
$('#fixed-bar').fadeOut(200);
}
});
});
</script>
<div id='fixed-bar'>
Hello
</div>
Actually I want to center the bar. How can I do this?