我是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