我試圖創建一個水平列表唱歌的HTML和CSS,但是當在瀏覽器中顯示它似乎下降的步驟,而不是在一條直線,任何想法可能會導致這一點?水平列表顯示在行
CSS
#nav li a {
display:block;
float:left;
text-indent: -9999px;
height: 50px;
width: 150px;
background-image:url(images/buttons.gif);
background-repeat: no-repeat;
background-attachment: scroll;
background-position: 0% 0%;
background-clip: border-box;
background-origin: padding-box;
background-size: auto auto;
margin-left:15px;
}
#nav li a:hover {
opacity: 0.5;
}
#nav li.one a {
background-position: 0pt 0px;
}
#nav li.two a {
background-position: 0pt -88px;
}
#nav li.three a {
background-position: 0pt -176px;
}
HTML
<ul id="nav">
<li class="one"><a href="#"><strong>One</strong> Selected Works on Display</a></li>
<li class="two"><a href="#"><strong>Two</strong> Thoughts, Links, Inspiration & Miscellany</a></li>
<li class="three"><a href="#"><strong>Three</strong> Those Who Have & Continue to Inspire</a> </li>
</ul>
當div向下摺疊超過默認大小時,浮動不會保持對齊狀態。你必須使用「display:inline-block」規則設置li對齊方式 – thoughtpunch 2012-01-11 16:04:19
在「inline-block」甚至被髮明之前,人們就已經成功地使用了浮動功能來製作水平菜單。 – 2012-01-11 16:06:57