练习锚点标记和下拉菜单。在下面的代码中,下拉菜单不起作用。不知道为什么。包含文本“这是下拉菜单”的div应该显示在包含文本“这是文本,它的中心”的div的正下方,只要后者被搁置。两个div的宽度都相同。css下拉不起作用
html,body {
\t margin: 0px;
\t height: 100%;
\t /* [disabled]width: 100%; */
\t left: 0px;
\t top: 0px;
\t background-color: rgba(255,255,255,1);
}
.wrapper {
\t text-align: center;
\t margin-top: 0;
\t margin-left: auto;
\t height: 100%;
\t max-width: 960px;
\t background-color: rgba(0,0,0,1);
\t margin-right: auto;
\t position: relative;
}
.link1 {
\t height: auto;
\t width: 50%;
\t color: rgba(255,255,255,1);
\t margin-right: auto;
\t margin-left: auto;
\t background-color: rgba(204,204,204,1);
}
.link1 a {
\t text-decoration: none;
\t display: block;
}
.link1 a:hover {
\t text-decoration: underline;
\t background-color: rgba(255,0,0,1); \t
}
.link1 a:hover .dropdown {
\t display: block;
}
.dropdown
{
\t height: 25%;
\t width: 50%;
\t background-color: rgba(204,204,204,1);
\t margin-right: auto;
\t margin-left: auto;
\t text-align: center;
\t display: none;
}
<div class="wrapper">
<div class="link1">
<a href="http://www.hotmail.com">This is text. Its in center</a>
</div>
<div class="dropdown">This is dropdown menu</div>
</div>
这是因为您的.dropdown元素不是链接的兄弟。 – CBroe
可否请您提供代码示例,以便我可以更好地理解? –