我是Jquery的新手。我想知道我们如何使用margin:0 auto; jQuery脚本中的CSS代码。任何人都可以请帮我吗?这里的代码:Jquery CSS如何使用保证金:0自动
<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>
其实我想要中心吧。我怎样才能做到这一点?
你为什么试图用jQuery来设计吧?如果可能的话,你应该在CSS中保留你的样式。 – chipcullen 2012-04-25 14:40:01
你想水平或真实地居中放置吧台吗? – Maverick 2012-04-25 14:41:14
我无法居中吧。你可以请张贴工作代码,无论是与CSS或风格的酒吧与jQuery?我会很感激你的帮助。 – 2012-04-25 14:42:25