martyyyy martyyyy - 1 year ago 93
HTML Question

Horizontal sub menu

I'd like to create horizontal submenu. Hovewer now I created only dopdown submenu. I have following css and html code, please see demo:

Can you help me improve my code? Thank you.


<ul id="menu-main-menu" class="top_big_menu"><li id="menu-item-4192" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-4192"><a href="#">Home</a></li>
<li id="menu-item-4159" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-4159"><a href="#">Football</a><ul>
<li><a href="#">News</a></li>
<li><a href="#">Interviews</a></li>
<li><a href="#">Comments</a></li>
<li id="menu-item-4160" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-4160"><a href="#">Football 2</a><ul>
<li><a href="#">News 2</a></li>
<li><a href="#">Interviews 2</a></li>
<li id="menu-item-4161" class="menu-item menu-item-type-taxonomy menu-item-object-category current-menu-item menu-item-4161"><a href="#">Football 3</a><ul>
<li><a href="">News 3</a></li>
<li><a href="">Interviews 3</a></li>
<li id="menu-item-4190" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-4190"><a href="#">Menu 4</a></li>
<li id="menu-item-4189" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-4189"><a href="#">Menu 5</a></li>


.top_big_menu li{
display: inline-block;
float: none;
position: relative;
bottom: -10px;
float: left;

.top_big_menu li a{
font-family: 'Calibri',sans-serif;
font-weight: bold;
font-size: 20px;
color: #212121;
text-transform: uppercase;
display: block;
padding-left: 20px;
padding-right: 20px;
line-height: 50px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;

.top_big_menu li a:hover{
background-color: #E31E24;
color: #fff;
text-decoration: none;

.top_big_menu .current-menu-item a, .top_big_menu .current_page_item a{
background-color: #E31E24;
color: #fff;

.top_big_menu li ul{
display: none;

.top_big_menu li:hover ul{ display:inline;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px; }

Answer Source
position: relative;

Apply the above code instead of applying position:relative to .top_big_menu li{} Check this link.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download