2

我的结果: http: //i.imgur.com/P50RS.png 我的 style.css

body {
background: url("img/bgs.png") repeat #cccccc;
color: #000000;
}


main {
margin-left: auto;
margin-right: auto;
}

我的 index.html

<html>
<head>
<title>Progress</title>
<link rel="stylesheet" href="css3-progress-bar.css" />
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link type="text/css" href="style.css" rel="stylesheet" />
</head>

<body>


<div id="main">
<p><b>215/160 LBS.</b></p>
<div class="bar_mortice rounded green_mortice">
      <div class="progress rounded green" style="width: 05%;"></div>
    </div>
</div>


</body>

</html>

为什么文本不居中?此外,直到我添加进度条才居中

margin: 0 auto;

我在 main 下尝试过,但没有运气。有任何想法吗?

4

1 回答 1

5

在 css 中,您需要使用#main而不仅仅是main.

此外,您需要给它一些宽度,否则它可能会占据整个宽度。尝试这个:

#main {
margin-left: auto;
margin-right: auto;
width: 50%;
}
于 2013-01-12T19:16:42.653 回答