-2

在以下代码中寻找一些帮助设置子菜单的样式。目前不显示子菜单项。我希望他们在悬停时下降。有什么建议么?我对这一切都很陌生,所以我非常感谢任何建议或帮助。谢谢。

                <nav id="navbar_text">
                    <ul>
                    <li><a href="index.html">Home</a></li>
                    <li><a href="aboutus.html">About</a></li>
                    <li><a href="#">Products</a></li>

                        <ul class="submenu">
                        <li><a href="index.html">Fireplaces & Accessories</a></li>
                        <li><a href="aboutus.html">Stoves</a></li>
                        <li><a href="aboutus.html">Outdoor Kitchens</a></li>
                        <li><a href="aboutus.html">Gas Grills</a></li>
                        </ul>

                    <li><a href="#">Services</a></li>

                        <ul class="submenu">
                        <li><a href="index.html">Chimney Services</a></li>
                        <li><a href="aboutus.html">Gas Services</a></li>
                        <li><a href="aboutus.html">Custom Design</a></li>
                        </ul>
                    </ul>
                 </nav>

            </div> <!--END navbar-->


#navbar_text a:link{
    color: #bca380;
}

#navbar_text a:hover{
    color: #dccfbd;
}

#navbar_text {
    word-spacing: 15px;
}

#navbar_text li{
    display:inline;
}


#navbar_text ul li a {
    display:inline;
    padding: 5px;
    background: #663333;
    margin-top: 5px;
    font-family:Georgia, "Times New Roman", Times, serif;
    font-size: 150%;
    color: #bca380;
    text-decoration: none;

}

ul.submenu {


       display: none;


        }


li:hover ul.submenu {

        display: block;
                }
4

1 回答 1

1

您需要将子菜单 ul 放在 li 元素中,如下所示:

<nav id="navbar_text">
    <ul>
        <li><a href="index.html">Home</a></li>
        <li><a href="aboutus.html">About</a></li>
        <li><a href="#">Products</a>
            <ul class="submenu">
                <li><a href="index.html">Fireplaces & Accessories</a></li>
                <li><a href="aboutus.html">Stoves</a></li>
                <li><a href="aboutus.html">Outdoor Kitchens</a></li>
                <li><a href="aboutus.html">Gas Grills</a></li>
            </ul>
        </li>
        <li><a href="#">Services</a>
            <ul class="submenu">
                <li><a href="index.html">Chimney Services</a></li>
                <li><a href="aboutus.html">Gas Services</a></li>
                <li><a href="aboutus.html">Custom Design</a></li>
            </ul>
        </li>
    </ul>
</nav>
于 2013-08-03T17:12:28.097 回答