2011-12-17 84 views
-1

我正在使用CSS在Html中編寫網站;在我的網站我有我想要的網站,我使用CSS的頂部中間尺寸才能將低於css填充,位於網頁上部中心的位置文本

background-color:#4d5152; 
position:fixed; 
width:970px; 
top: 0%; 
padding-right:200px; 
padding-left:200px; 

我的問題是這樣表示的文字標識,我怎麼能在上部中央位置我的標誌並且使徽標的左右尺寸與徽標的顏色相同,而無需將值左右填充;所以這將是通用於所有電腦顯示器的尺寸和瀏覽器 希望我足夠清晰的 感謝您的幫助

+0

是您的徽標?把你的HTML和CSS放在這裏。 – 2011-12-17 12:09:45

+0

不,它位於由CSS覆蓋的HTML頁面中 – user723686 2011-12-17 12:13:17

+0

您應該通過'HTML'的'TAG'來了解更多關於'HTML'的信息。並且應該用'position:fixed'來詳細瞭解'CSS'。 – 2011-12-17 12:15:33

回答

1

通常情況下,我會寫這樣的事:

HTML

<html> 
<body> 
    <div id="wrapper">   
     <h1 id="logo">My Company</h1> 
    </div> 
</body> 
</html> 

CSS

#wrapper { 
    width:960px; /* Width of the containing 'wrapper' or content area */ 
    margin:0 auto; /* This will center the wrapper. 0px margin on the top and bottom, and 'auto' on the left and right (let the browser decide the amount of margin). */ 
} 

h1#logo { 
    text-align:center; /* If you don't define a width the h1 will be 100% as its parent (#wrapper). This centers the text. */ 
} 

下面是一個顯示此示例的示例:http://jsfiddle.net/V5Cff/1/embedded/result/