Reputation: 31
I have this menu that I have been working on for a while. I am using the CSS table displays to accomplish it. When the text inside of my links take up two lines, the ones that are only one line will not fill the parent li on hover. Is there any way I am missing that can accomplish this?
css
.menu {
background-color: #687c9e;
display: table;
}
.menu-list {
display: table-row;
}
.menu-list > li {
display: table-cell;
height: 100%;
overflow: hidden;
line-height: 1.125rem;
overflow: auto;
}
.menu-list > li > a {
display: block;
color: #fff;
text-decoration: none;
padding: 1.25rem 1.25rem 1.25rem 0;
box-sizing: border-box;
height: 100%;
min-height: 2.25rem;
}
.menu-list > li > a:hover {
background-color: #7889a8;
}
.dropdown-list {
display: none;
}
.hidden {
display: none;
}
html
<nav class="content menu">
<ul class="menu-list">
<li><a href="">Home</a></li>
<li><a href="">A really long</a></li>
<li><a href="">Some really long word</a></li>
<li><a href="">Special Events</a></li>
<li><a href="">Newsletter</a></li>
<li><a href="">Photo Gallery</a></li>
</ul>
</nav>
Upvotes: 1
Views: 1663
Reputation: 631
See This link: this may help you: https://jsfiddle.net/guruWork/8fwo0r06/2/
<nav class="content menu">
<ul class="menu-list">
<li><a href=""><span>Home</span></a></li>
<li><a href=""><span>A really long</span></a></li>
<li><a href=""><span>Some really long word</span></a></li>
<li><a href=""><span>Special Events</span></a></li>
<li><a href=""><span>Newsletter</span></a></li>
<li><a href=""><span>Photo Gallery</span></a></li>
</ul>
</nav>
And CSS
.menu {
background-color: #687c9e;
}
.menu-list {
display: table;padding:0; margin:0;width:100%;
}
.menu-list > li {
display: table-cell;
height: 100%;
overflow: hidden; vertical-align: top;
overflow: auto;
}
.menu-list > li > a {
display: table;
color: #fff;
text-decoration: none;
padding: 0;
box-sizing: border-box;
height: 100%;
min-height:53px; text-align:center;
}
.menu-list > li > a span{display: table-cell;padding: 5% .5rem;vertical-align: middle;}
.menu-list > li > a:hover {
background-color: #7889a8;
}
.dropdown-list {
display: none;
}
.hidden {
display: none;
}
Upvotes: 0
Reputation: 4525
the reason why it didn't fill the entire li 'coz you're just filling the anchor
hover the li
instead of the anchor
.menu-list > li:hover {
background-color: #7889a8;
}
Upvotes: 0
Reputation: 2169
Simply remove the padding from your li
, and add it to your menu-list
, check out the link below;
Upvotes: 1