那個看起來像表格的東西其實是用 span + CSS 做出來的
選單的 html 與 css 分別是
代碼:
<div class="MainMenu2">
<span><a href="..." title="本署簡介">本署簡介</a></span>
<span><a href="..." title="........">........</a></span>
......
</div>
代碼:
.MainMenu2 {
border-right: 1px solid #FFFFFF;
border-left: 1px solid #FFFFFF;
border-top: 1px solid #8C7926;
border-bottom: 2px solid #8C7926;
background: #634B0D url(../images_3/MainMenu2Bg_2.gif);
text-align: right;
width: 755px;
padding: 2px 10px;
}
.MainMenu2 a {
background: url(../images_3/BulletMmenu.gif) no-repeat 2px 2px;
font-size: 75%;
white-space: nowrap;
text-decoration: none;
color: #FBF8D0;
display: inline-block;
border-right: 1px solid #B5B2B2;
border-bottom: 1px solid #B5B2B2;
text-align: right;
padding-top: 1px;
padding-right: 2px;
margin-top: 2px;
width: 7em;
}
.MainMenu2 a:hover {
background: url(../images_3/BulletMmenum.gif) no-repeat 2px 2px;
text-decoration: none;
color: #FFFFFF;
border-right: 1px solid #FFCC99;
border-bottom: 1px solid #FFCC99;
}
其中,那個 display: inline-block 好像是 IE Only 的語法
因為我在 W3C 查不到這個東西
最簡單的方法 要讓這東西看起來整齊的話
依據 W3C 標準
應改成 display: table-cell
但 IE 應該尚未支援這個屬性
所以呢... 直接在 HTML 改用 table 比較簡單啦~
真的想用 CSS... 那 HTML 最好改一下
把想放在同一欄的 item 用 div 包起來
會比較好處理
可以參考
這一篇的作法。