我制作了一个导航栏,并且有一个下拉菜单。我需要找到一种方法在下拉菜单后面放置一个框,因为当您尝试阅读菜单时,所有内容都会显示在下面。这是我到目前为止所拥有的html。我还没有链接任何东西,但从视觉上看它是有效的。
* {
box-sizing: border-box;
}
body {
margin: 0;
}
.navbar {
overflow: hidden;
background-color: #333;
font-family: Aclonica, Arial, Helvetica, sans-serif;
}
.navbar a {
float: left;
font-size: 30px;
color: white;
text-align: center;
padding: 16px 16px;
text-decoration: none;
}
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 30px;
border: none;
outline: none;
color: white;
padding: 15px;
background-color: inherit;
font: inherit;
margin: 0;
}
.navbar a:hover, .dropdown:hover .dropbtn {
background-color: #B598F9;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #B598F9;
width: 100%;
left: 0;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content .header {
background: #B598F9;
padding: 5px;
color: white;
}
.dropdown:hover .dropdown-content {
display: block;
}
/* Create three equal columns that floats next to each other */
.column {
float: left;
width: 33.33%;
padding: 10px;
background-color: #B598F9;
height: 100px;
}
.column a {
float: none;
color: black;
padding: 16px;
text-decoration: none;
display: block;
text-align: left;
}
.column a:hover {
background-color: #B598F9;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
@media screen and (max-width: 600px) {
.column {
width: 100%;
height: auto;
}
}
.center {margin:auto;
width: 50%;}
`<div class="navbar">
<a href="#home"> <img src="images/lotus_painting.png"
type="images/lotus_painting.png"
rel="icon" height="75px" width="75px"></a>
<a href="#">Artists <br>Hour</a>
<!--This is the page list of artists-->
<div class="dropdown">
<button class="dropbtn" style="font-size:30px">School <br>of Art
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<div class="header">
<h1>Where Would You Like To Go?</h1>
</div>
<div class="row">
<div class="column">
<h1>Art Study</h1>
<a href="#">Fundamentals</a>
<a href="#">Tutorials</a>
</div>
<div class="column">
<h1>How To...</h1>
<a href="#">Upgrade Your <br>Art Business</a>
<a href="#">Have A Good <br>Portfolio</a>
<a href="#">Achieve <br>Multi-Stream<br> Income</a>
</div>
<div class="column">
<h1>Business</h1>
<a href="#">Tax Facts</a>
<a href="#">Terms of Service<br> Checklist</a>
<a href="#">How To Be<br> Prepared To <br> Talk To A <br>Lawyer</a>
</div>
</div>
</div>
</div>
</div>
我尝试过在每个盒子后面创建盒子(据我所知),但它看起来很糟糕。我希望找到一种方法让整个区域超越“你想去哪里?”拥有自己的盒子,但我觉得我缺少一大块代码来实现这一点。在此失落又焕然一新......
我通过玩所有代码找到了答案
/* Create three equal columns that floats next to each other */
.column {
float: left;
width: 33.33%;
padding: 10px;
background-color: #B598F9;
height: 400px;
}
只需调整高度即可将其全部封装起来。