2015-12-03 52 views
-1

無論我做什麼,我的文字鏈接都會繼續向左對齊。 CSS的是:如何將文字居中?

p { 
 
    float: center; 
 
    text-align: center; 
 
    font-size: 20px; 
 
    font-family: Gotham-Bold; 
 
    src: url(Gotham-Bold.otf); 
 
}
<header> 
 

 
    <h2> <img src="Links Link.png" text-align="center" width="207" height="106"></h2> 
 

 
</header> 
 

 
<p> <a href="http://www.chicagotribune.com/entertainment/ct-talking-pictures-mpaa-ratings-20140828-column.html"> Click here to learn about the "Love Actually" controversy </a> 
 
</p> 
 
<p> <a href=: "http://apecsec.org/mpaa-rating-system-controversy/"> Click here for more information on the MPAA rating system </a> 
 
</p> 
 
<p> <a href="http://www.cnn.com/2012/03/08/showbiz/movies/bully-rating-controversy-ew/"> Click here to learn about the "Bully" controversy </a> 
 
</p> 
 
<p> <a href="https://petitions.whitehouse.gov/petition/investigate-chris-dodd-and-mpaa-bribery-after-he-publicly-admited-bribing-politicans-pass"> TAKE ACTION! Sign the petition here </a> 
 
</p>

有誰知道這是我在做什麼錯誤?

+3

不要以爲「浮動:中心」存在 – ggdx

+1

你在查看此?這會產生以下視圖 - http://jsfiddle.net/brettdewoody/u4g7hfp3/ –

+2

浮點數沒有'center'值... –

回答

0

Nix the float:center; 「中心」不存在作爲浮動的屬性。

那就試試這個:

p { 
    width:100%; 
    display:block; 
    text-align: center; 
    font-size: 20px; 
    font-family: Gotham-Bold; 
} 

fiddle

+0

大家知道,'p'總是'display:block',所以不需要添加它。 –

0

我得到你的代碼想要的行爲......

哪裏是你的CSS positionned? (該目錄相比,HTML)

確保使用這樣的

<head> 
    ... 
    <link rel="stylesheet" href="mycss.css"/> 
</head>