2012-08-24 21 views
3

所以即時通訊設計一個網站在CSS中,即時通訊嘗試將我的導航欄(帶有鏈接的標題)居中,但是當我使用「文本對齊:中心」和「邊距:自動」屬性時,它不起作用。這是我的HTML文件代碼:如何將標題鏈接置於CSS中?

<html> 
    <head> 
    <meta http-equiv="Content-Type" 
     content="text/html;charset=ISO-8859-1"> 
    <title>Brickwood Fire Dept. - Established 2008</title> 
    <link type="text/css" 
     rel="stylesheet" href="main_style.css" media="screen" 
    </head> 
<body> 
    <h1> 
    Brickwood Fire Department 
    </h1> 
    <h2> 
    Established 2008 
    </h2> 
    <h3> 
    <a class = "home" href = "http://www.brickwoodfiredept.weebly.com">Home</a> 
    <a href = "http://www.brickwoodfiredept.weebly.com/contact-us">Contact</a> 
    <a href = "http://www.brickwoodfiredept.weebly.com/media.html">Media</a> 
    <a href = "http://www.brickwoodfiredept.weebly.com/links">Links</a> 
    <a href = "http://www.brickwoodfiredept.weebly.com/newsletter">Newsletter</a> 
    </h3> 
</body> 
</html> 

這裏是我的CSS代碼:

a { 
    color : white ; 
    background : #32C1DA ; 
    width : 30% ; 
    text-align : center ; 
    font-family : Arial ; 
    font-size : 150% ; 
    margin : auto ; 
    word-spacing : normal 
} 

的CSS代碼的其餘部分被省略了以節省空間。

回答

0

嘗試增加

display:block; 

到你的CSS

+0

唯一的問題是我希望他們像這樣佈置:「主頁布拉布拉布拉布拉」。 –

0

您需要margin:auto;父(H3標籤)和text-align:center;對孩子(標籤)。

+0

非常感謝!這工作。我認爲菲利普試圖說這個,但沒有正確地說出來。非常感謝你! –

+0

@ user1621272您可以點擊有用答案上的向上箭頭以及您認爲正確答案旁邊的複選標記。 – styfle

3

嘗試在h3標籤上放置文本對齊而不是標籤。

h3 { text-align:center; } 
1

簡單的答案是:

h3 { 
    text-align:center; 
} 
0

像這樣 H3 {寬度:30%; text-align:center; } a {color:white;背景:#32C1DA;寬度:30%; text-align:center; font- family:Arial; font-size:150%;保證金:汽車;字間距:正常}