我强烈建议为此使用列表,您认为合适的顺序或无序;如果只是因为语义(导航菜单是您可能希望去的页面列表),而table
应该以表格格式显示数据。也就是说,我建议:
<header>
<ul>
<li>Home</li>
<li>Gallery</li>
<li>Location</li>
<li>Rates</li>
<li>Contact</li>
</ul>
</header>
使用 CSS:
header ul {
width: 100%;
font-size: 0; /* to remove the white-space gaps between the li elements */
text-align: center; /* to center the list, amend as appropriate */
}
header ul li {
font-size: 16px; /* to explicitly reset the font-size and
override that of the parent */
display: inline-block; /* to allow for wrapping */
width: 19%; /* a baseline width, if the monitor is wide enough to allow it */
min-width: 7em; /* a minimum width, if the 19% of the width of the ul is less than
7em, the li elements will wrap to the next line, rather than
becoming too small to be functional */
border: 1px solid #000;
-webkit-box-sizing: border-box; /* To explicitly include the border in the width
of the element */
-moz-box-sizing: border-box;
-o-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
JS 小提琴演示。