練習錨點標記和下拉菜單。在下面的代碼中,下拉菜單不起作用。不知道爲什麼。包含文本「這是下拉菜單」的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
可否請您提供代碼示例,以便我可以更好地理解? –