html - CSS ul下拉列表问题

标签 html css drop-down-menu html-lists

<分区>

我以前问过这样的问题,但没有得到任何答复。这很重要,因为它是我网站不可或缺的一部分。

我正在尝试创建一个下拉菜单。 “团队”和“新闻”链接(当您将鼠标悬停在它们上面时)是问题所在。我希望它们下面的链接与其父级一致。

我试图通过填充解决问题,但毫无进展。

请帮忙。

http://codepen.io/DocRow10/pen/hjIkq

<body>
        <div id="container">
            <div id="banner" class="clearfix">

                        <img id="crest" src="images/cecc-logo.png" />
                        <h1>Test Website</h1>
            </div>
            <nav class="clearfix">
                <ul class="clearfix">
                    <li><a href="#">Home</a></li>
                    <li><a href="#">About</a></li>
                    <li><a href="#">News</a>
                        <ul>
                            <li><a href="#">Social Events</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Team</a>
                        <ul>
                            <li><a href="#">Players</a></li>
                            <li><a href="#">Fixtures/Results</a></li>
                            <li><a href="#">Statistics</a></li>
                        </ul>
                    </li>
                    <li><a href="#">Gallery</a></li>
                    <li><a href="#">Contact</a></li>  
                </ul>
                <a href="#" id="pull">Menu</a>
            </nav>
            <main>

            </main>
            <footer>

            </footer>
        </div>

    </body>
</html>





body {
  background-color: rgb(200, 220, 255);
/* #455868 */

}

#container {
    height: 1000px;
    margin-left: auto;
    margin-right: auto;
}

#banner {
    width: 100%;
    text-align: center;

}

#crest {
    height: 150px;
    width: 180px;
    display: inline-block;
}

#banner h1 {

    display: inline-block;
}
/* Bat Colour rgb(38, 124, 196); */


@media only screen and (min-width : 480px) {


    #banner h1 {
        font-size: 30px;
        display: inline-block;
    }
}

@media only screen and (min-width : 768px) {
    #banner h1 {
        font-size: 36px;
        display: inline-block;
    }
}
@media only screen and (min-width : 980px) {
    #banner h1 {
        font-size: 47px;
        display: inline-block;
    }
}

nav {
    height: 40px;
    width: 90%;
    margin-left: auto;
    margin-right: auto;
    background-color: rgb(238, 0, 0);
    font-size: 13pt;
    font-family: neris;
    border-bottom: 2px solid #283744;
}

nav > ul {
    padding: 0;
    margin: 0 auto;
    width: 600px;
    height: 40px;
}

nav > ul > li {
    display: inline;
    float: left;
}

nav ul a {
    color: #fff;
    display: inline-block;
    width: 100px;
    text-align: center;
    text-decoration: none;
    line-height: 40px;
    text-shadow: 1px 1px 0px #283744;
}

nav li a {
    border-right: 1px solid #576979;
    box-sizing:border-box;
    -moz-box-sizing:border-box;
    -webkit-box-sizing:border-box;
}
nav li:last-child a {
    border-right: 0;
}

nav a:hover, nav a:active {
    background-color: #8c99a4;
}

nav a#pull {
    display: none;
} 

nav ul li:hover ul {
    display: block;
}

nav ul ul {
    display: none;
    position: absolute;
}

nav ul ul li {
    display: block;
}

main {
    width: 90%;
    height: 200px;
    margin-right: auto;
    margin-left: auto;
    background-color: rgb(38, 124, 196);
}

footer {
    width: 90%;
    height: 50px;
    margin-right: auto;
    margin-left: auto;
    background-color: rgb(0, 0, 0);
}

最佳答案

如果我理解正确,这应该有帮助:

ul ul {
  padding: 0;
}

关于html - CSS ul下拉列表问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35516393/

相关文章:

javascript - 如何判断在表中的 href 中单击了哪个行号?

html - 使用内容扩展 div,而不移动其下方的元素

html - pdfHTML 不遵循 CSS 样式

css - 我可以在 CSS 中混合固定的左偏移量和相对宽度吗?

javascript - jQuery 菜单 - 如何添加鼠标事件?

javascript - 更改宽度以使高度适合窗口屏幕?

javascript - webpack导入css文件出错

javascript - 如何消除水平滚动条?

css - data-toggle ="collapse"单击菜单时菜单消失

php - 下拉列表始终列出 codeigniter 中的所有值