【发布时间】:2015-04-20 04:25:54
【问题描述】:
我无法将网页内容居中。目前在我的移动设备上看起来像这样:
我希望将这个页面的所有内容在屏幕上居中,并让宽度填满页面。
我的 HTML 如下:
<html>
<head>
<link rel="stylesheet" media="screen and (max-device-width: 799px)" type="text/css" href="stylesheet_small.css" />
<link rel="stylesheet" media="screen and (min-device-width: 800px)" type="text/css" href="stylesheet_large.css" />
<div class ="container_header">
<div class="header">
<div class="nav">
<a href="index.php" class="body">HOME</a>.....etc.
</div>
</div>
</div>
</head>
<body>
<p id="content">
<div class="container_top">
<div id="logo"><img border="0" src="images/introspect_logo_container.png" alt="INTROSPECT PICTURES" align="center"></div>
</div>
<div class ="container_body">
<br><div class ="current_page"><b>INTROSPECT</b> HOME</div>
<hr>
....
<div id="featured_pic"><img border="0" src="images/index_fliers.jpg" alt="FLIERS" align="center"></div>
</div>
</p>
</body>
<div class="footer">
....
</div>
</html>
stylesheet_small 的 CSS 如下所示:
body {
text-align: center;
}
.header {
width:auto;
text-align: center;
padding:10px;
border-radius: 5px;
}
.container_top {
text-align: center;
width:auto;
border-radius: 5px;
}
.container_body {
text-align: center;
width:auto;
padding:10px;
border-radius: 5px;
}
#logo {
width: auto;
}
#featured_pic {
width: auto;
}
我已将文本和图像居中对齐,并将每个类的宽度设置为auto。我还需要做什么?谢谢。
【问题讨论】:
标签: html css alignment width center