Reputation: 75
I've got this dropdownmenu for my site and I wanted to add border-bottom to the menu but the border appears too wide. I've checked every step of: Border too wide because of margin because it seemed the same problem, but nothing worked.
Hope you can help me out!!
Here's de css code:
#dropdownmenu a {
color:inherit !important;
text-decoration:none !important}
#dropdownmenu {
width:1050px;
background:#137cd7;
z-index:2;
position:relative }
#dropdownmenu ul {
text-align:left;
display:inline;
margin:0px;
padding:10px 4px 25px 0;
list-style:none }
#dropdownmenu ul li {
display:inline-block;
margin-right:10px;
position:relative;
padding:15px 15px 14px;
cursor:pointer;
-webkit-transition:all 0.2s;
-moz-transition:all 0.2s;
-ms-transition:all 0.2s;
-o-transition:all 0.2s;
transition:all 0.2s;
color:#fff }
#dropdownmenu ul li:hover {
background-color:#ffffff;
color:#137cd7 }
@media screen and (-webkit-min-device-pixel-ratio:0)
#dropdownmenu ul li ul {
top:44px !important}
#dropdownmenu ul li ul {
padding:0px;
position:absolute;
top:47px;
left:0px;
width:170px;
display:none;
opacity:0;
visibility:hidden;
-webkit-transiton:opacity 0.2s;
-moz-transition:opacity 0.2s;
-ms-transition:opacity 0.2s;
-o-transition:opacity 0.2s;
-transition:opacity 0.2s }
#dropdownmenu ul li ul li {
background-color:#fff;
display:block;
color:#222;
border-left:1px solid #ccc;
border-right:1px solid #ccc;}
#dropdownmenu ul li ul li:hover {
color:#137cd7;
background:#fff;
text-decoration:none !important }
#dropdownmenu ul li:hover ul {
display:block;
opacity:1;
visibility:visible;
border-bottom:1px solid #ccc; }
And HTML:
<div id="dropdownmenu">
<ul>
<li>
<a href="/">Home</a></li>
<li>
<a href="/">Menu 1</a>
<ul>
<li>
<a href="/">Submenu</a></li>
<li>
<a href="/">Submenu</a></li>
<li>
<a href="/">Submenu</a></li>
<li>
<a href="/">Submenu</a></li>
<li>
<a href="/">Submenu</a></li>
<li>
<a href="/">Submenu</a></li>
<li>
<a href="/">Submenu</a></li>
</ul>
</li>
<li>
<a href="/">Menu 2</a>
<ul>
<li>
<a href="/">Submenu</a></li>
<li>
<a href="/">Submenu</a></li>
<li>
<a href="/">Submenu</a></li>
<li>
<a href="/">Submenu</a></li>
<li>
<a href="/">Submenu</a></li>
<li>
<a href="/">Submenu</a></li>
<li>
<a href="/">Submenu</a></li>
</ul>
</li>
<li>
<a href="/contact">Contact</a>
<ul>
<li>
<a href="/contact"><img alt="" src="/files/19731/editor/images/support(1).JPG" style="width: 140px; height: 140px; border-width: 0px; border-style: solid;" /></a></li>
<li>
</li>
</ul>
</li>
</ul>
Thanks everyone!
I added this code which worked for me: #dropdownmenu ul li ul li { margin-right: 0;}
This one worked as well: 1) remove the border from #dropdownmenu ul li ul li {border-left:0; border-right:0} and add border to the #dropdownmenu ul li:hover ul {border:1px solid #ccc; border-top:0;}
Upvotes: 0
Views: 1083
Reputation: 1234
Two solutions you can take
1) remove the border from #dropdownmenu ul li ul li {border-left:0; border-right:0}
and add border to the #dropdownmenu ul li:hover ul {border:1px solid #ccc; border-top:0;}
2) add border-bottom to the last element of #dropdownmenu ul li ul li
#dropdownmenu ul li ul li:last {border-bottom: 1px solid #ccc;}
if browser support is not an issue
Upvotes: 0
Reputation: 4904
Removed border style from here
#dropdownmenu ul li:hover ul
and added here
#dropdownmenu ul li ul li:last-child {
border-bottom:1px solid #ccc;
}
CSS selector :last-child
browser support stat's here
Upvotes: 1
Reputation: 8651
It is caused by:
#dropdownmenu ul li {
margin-right:10px;
}
That margin is causing your dropdown menu to expand wider than it should. Try adding:
#dropdownmenu ul li ul li {
margin-right: 0;
}
Upvotes: 1