對於包含h3和表的部分,我有兩個div id。我希望它中心一致,但我似乎無法讓它做到這一點。我已經嘗試了幾件事,但我認爲我可能做錯了。div中的居中表
這是我的HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Metra Train Schedule</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
<!-- Attempt at adding favicon-->
<link rel="icon" type="image/x-icon" href="<a href="img/favicon.ico"></a>
</head>
<body>
<div id="header"><img src="img/Header.jpg" /></div>
<div id="content">
<hgroup>
<h1>Metra Rails</h1>
<h2>District/North Line in Chicago</h2>
</hgroup>
<h3><a href="#inbound">Inbound Schedule</a></h3>
<h3><a href="#outbound">Outbound Schedule</a></h3>
<p>
... <a href="http://metrarail.com/content/metra/en/home/utility_landing/riding_metra/riding_metra.html">here.</a>
</p>
<hr>
<div id="inbounds">
<h3>Milwaukee District/North Line (Mayfair to Chicago)</h3>
<table id="inbound">
<caption>Inbound Schedule: Sunday</caption>
<tbody>
...
</tbody>
</table>
</div>
<hr>
<div id="outbounds">
<h3>Milwaukee District/North Line (Chicago to Mayfair)</h3>
<table id="outbound">
<caption>Outbound Schedule: Sunday</caption>
<tbody>...</tbody>
</table>
</div>
<div class="other"><h2>To see schedules for other days click <a href="http://metrarail.com/metra/en/home/maps_schedules/metra_system_map/md-n/schedule.full.html">here.</a></div>
</div>
</body>
</html>
這是我的CSS
@charset "utf-8";
/* CSS Document */
body {
background:url(img/background_texture.jpg) no-repeat center center fixed;
background-size: cover;
color: white;
}
h1 {
margin: 0px;
}
#header {
width: 1020px;
padding: 0px;
margin: 0 auto;
}
#header img {
vertical-align: bottom;
}
#content {
background-image:url(img/ContentBox.png);
background-repeat: no-repeat;
background-position:center;
padding: 0
px;
width: 1020px;
margin: 0 auto;
}
table, td, th {
border: 1px solid white;
border-collapse: collapse;
padding: 4px;
text-align: center;
}
th {
font-size: 1.25em;
font-weight: bolder;
}
td {
font-weight: bold;
}
caption {
font-size: 2em;
font-weight: bold;
}
tr:nth-child(even) {
background-color:#d39a11
}
tr:nth-child(odd) {
background-color:#363c40
}
.stop {
text-align: right;
}
a:link {
color: #d39a11;
}
a:visited {
color:#7E6201;
}
a:hover {
color:#FB992D
}
a:active {
color: d39a11;
}
#inbounds, #outbounds {
text-align: center;
}
這裏是一個圖片,以幫助...
'table {width:800px;保證金:0汽車; }' – mdesdev