I want to increase the transparent area between my dropdown button and its content so that the dropdown content lines up with the bottom of my navbar. I've tried using vertical-align: top in my code, which doesn't work.
Because I'm unsure of whether or not something in my navbar code is affecting the dropdown content, the code for both the dropdown/navbar is shown below.
.navbar {
verical-align: top;
margin: 0;
padding: 0em;
background-color: #f79256;
overflow: hidden;
text-align: center;
width: 100vw;
padding: .5em;
}
.navbar a {
vertical-align: top;
float: center;
display: inline-block;
position: relative;
overflow-y: hidden;
color: #fbfffa;
text-decoration: none;
font-family: "Quicksand", sans-serif;
font-size: 1.5em;
margin-left: 0.75em;
margin-right: 0.75em;
}
.navbar a:after {
content: '';
width: 0; height: 3px;
display: block;
margin-top: 1px;
right: 0;
background: #fbb68e;
transition: width .2s ease;
}
.navbar a:hover:after {
width: 100%;
left: 0;
background: #fbb68e;
}
/* dropdown part of nav bar */
.dropdown {
float: center;
display: inline-block;
overflow: hidden;
vertical-align: top;
}
.dropdown .dropdown-button {
background: #f79256;
color: #fbfffa;
font-family: "Quicksand", sans-serif;
font-size: 1.5em;
vertical-align: top;
position: relative;
outline: none;
border: none;
margin-left: 1em;
margin-right: 1em;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #fffef0;
box-shadow: 0px 4px 8px 0px #f0e6d6, 0px 6px 20px 0px #f0e6d6;
z-index: 1;
padding: 0px 0px 7.5px 0px;
}
.dropdown-content a {
display: block;
text-align: left;
float: none;
font-family: "Quicksand", sans-serif;
font-size: 1.2em;
color: #033d4f;
text-decoration: none;
}
.dropdown-content a:hover {
text-decoration: underline 2.5px #15c1a4;
text-underline-offset: 0.15em;
}
.dropdown-content a:hover:after {
animation-name: none;
width: 0;
}
.dropdown:hover .dropdown-content {
display: block;
}
<div >
<a href="index.html">home</a>
<div >
<button >about</button>
<div >
<a href="purpose.html">purpose</a>
<a href="team.html">our team</a>
</div>
</div>
<a href="important.html">important</a>
<a href="contact.html">contact</a>
</div>
CodePudding user response:
Try by adding some margin to the dropdown-content
element
.navbar {
verical-align: top;
margin: 0;
padding: 0em;
background-color: #f79256;
overflow: hidden;
text-align: center;
width: 100vw;
padding: .5em;
}
.navbar a {
vertical-align: top;
float: center;
display: inline-block;
position: relative;
overflow-y: hidden;
color: #fbfffa;
text-decoration: none;
font-family: "Quicksand", sans-serif;
font-size: 1.5em;
margin-left: 0.75em;
margin-right: 0.75em;
}
.navbar a:after {
content: '';
width: 0; height: 3px;
display: block;
margin-top: 1px;
right: 0;
background: #fbb68e;
transition: width .2s ease;
}
.navbar a:hover:after {
width: 100%;
left: 0;
background: #fbb68e;
}
/* dropdown part of nav bar */
.dropdown {
float: center;
display: inline-block;
overflow: hidden;
vertical-align: top;
}
.dropdown .dropdown-button {
background: #f79256;
color: #fbfffa;
font-family: "Quicksand", sans-serif;
font-size: 1.5em;
vertical-align: top;
position: relative;
outline: none;
border: none;
margin-left: 1em;
margin-right: 1em;
}
.dropdown-content {
margin-top: 10px;
display: none;
position: absolute;
background-color: #fffef0;
box-shadow: 0px 4px 8px 0px #f0e6d6, 0px 6px 20px 0px #f0e6d6;
z-index: 1;
padding: 0px 0px 7.5px 0px;
}
.dropdown-content a {
display: block;
text-align: left;
float: none;
font-family: "Quicksand", sans-serif;
font-size: 1.2em;
color: #033d4f;
text-decoration: none;
}
.dropdown-content a:hover {
text-decoration: underline 2.5px #15c1a4;
text-underline-offset: 0.15em;
}
.dropdown-content a:hover:after {
animation-name: none;
width: 0;
}
.dropdown:hover .dropdown-content {
display: block;
}
<div >
<a href="index.html">home</a>
<div >
<button >about</button>
<div >
<a href="purpose.html">purpose</a>
<a href="team.html">our team</a>
</div>
</div>
<a href="important.html">important</a>
<a href="contact.html">contact</a>
</div>
CodePudding user response:
by adding some padding to the dropdown-content
.navbar {
verical-align: top;
margin: 0;
padding: 0em;
background-color: #f79256;
overflow: hidden;
text-align: center;
width: 100vw;
padding: .5em;
}
.navbar a {
vertical-align: top;
float: center;
display: inline-block;
position: relative;
overflow-y: hidden;
color: #fbfffa;
text-decoration: none;
font-family: "Quicksand", sans-serif;
font-size: 1.5em;
margin-left: 0.75em;
margin-right: 0.75em;
}
.navbar a:after {
content: '';
width: 0; height: 3px;
display: block;
margin-top: 1px;
right: 0;
background: #fbb68e;
transition: width .2s ease;
}
.navbar a:hover:after {
width: 100%;
left: 0;
background: #fbb68e;
}
/* dropdown part of nav bar */
.dropdown {
float: center;
display: inline-block;
overflow: hidden;
vertical-align: top;
}
.dropdown .dropdown-button {
background: #f79256;
color: #fbfffa;
font-family: "Quicksand", sans-serif;
font-size: 1.5em;
vertical-align: top;
position: relative;
outline: none;
border: none;
margin-left: 1em;
margin-right: 1em;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #fffef0;
box-shadow: 0px 4px 8px 0px #f0e6d6, 0px 6px 20px 0px #f0e6d6;
z-index: 1;
padding-top: 10px;
padding: 0px 0px 7.5px 0px;
}
.dropdown-content a {
display: block;
text-align: left;
float: none;
padding : 10px 0 ;
font-family: "Quicksand", sans-serif;
font-size: 1.2em;
color: #033d4f;
text-decoration: none;
}
.dropdown-content a:hover {
text-decoration: underline 2.5px #15c1a4;
text-underline-offset: 0.15em;
}
.dropdown-content a:hover:after {
animation-name: none;
width: 0;
}
.dropdown:hover .dropdown-content {
display: block;
}
<div >
<a href="index.html">home</a>
<div >
<button >about</button>
<div >
<a href="purpose.html">purpose</a>
<a href="team.html">our team</a>
</div>
</div>
<a href="important.html">important</a>
<a href="contact.html">contact</a>
</div>
passing