我怎样才能使我的文字居中?

时间:2015-12-03 21:34:13

标签: html

无论我做什么,我的文字链接都会继续对齐左边。 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>
&#13;
&#13;
&#13;

有谁知道我做错了什么?

2 个答案:

答案 0 :(得分:0)

Nix the float:center; &#34;中心&#34;不作为浮动属性存在。

然后试试这个:

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

fiddle

答案 1 :(得分:0)

我的代码获得了想要的行为......

你的css定位在哪里? (哪个目录与html相比)

请务必像这样使用

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