2016-11-30 126 views
0

我想在HTML中創建子菜單。在這裏,我創建了菜單和子菜單,但它出現在左側,我想要下面的子菜單。請幫我this.i想要的子菜單中打開向下的一面,當光標放在它下面是關於它的CSS和HTML下拉菜單顯示在左側而不是下側作爲子菜單

/* header */ 
 

 
#templatemo_header_wrapper { 
 
    width: 100%; 
 
    height: 82px; 
 
    background: url(images/templatemo_header.png) repeat-x; 
 
} 
 
#templatemo_header { 
 
    width: 910px; 
 
    height: 52px; 
 
    padding: 15px; 
 
    margin: 0 auto; 
 
} 
 
/* site title */ 
 

 
#site_title { 
 
    float: left; 
 
    padding: 10px 0 0 0; 
 
} 
 
#site_title a { 
 
    margin: 0px; 
 
    padding: 0px; 
 
    font-size: 26px; 
 
    color: #ffffff; 
 
    font-weight: normal; 
 
    text-decoration: none; 
 
} 
 
#site_title h1 a:hover { 
 
    font-weight: bold; 
 
    text-decoration: none; 
 
} 
 
#site_title a span { 
 
    display: block; 
 
    margin-top: 5px; 
 
    color: #fff; 
 
    font-size: 11px; 
 
    text-align: center; 
 
} 
 
#templatemo_menu { 
 
    float: left; 
 
    height: 37px; 
 
    margin-top: 12px; 
 
    overflow: hidden; 
 
    position: relative; 
 
} 
 
#templatemo_menu ul { 
 
    margin: 0; 
 
    padding: 0; 
 
    list-style: none; 
 
} 
 
#templatemo_menu ul li { 
 
    padding: 0; 
 
    margin: 0; 
 
    display: inline; 
 
} 
 
#templatemo_menu ul li a { 
 
    float: left; 
 
    display: inherit; 
 
    height: 28px; 
 
    width: 100px; 
 
    margin-left: 0px; 
 
    padding: 8px 0 0 0; 
 
    text-align: center; 
 
    font-size: 13px; 
 
    font-weight: bold; 
 
    text-decoration: none; 
 
    color: #fff; 
 
    outline: none; 
 
} 
 
#templatemo_menu li a:hover, 
 
#templatemo_menu li .current { 
 
    background: url(images/menu_hover.png) no-repeat; 
 
} 
 
#templatemo:hover .dropdown-content { 
 
    display: block; 
 
} 
 
/* end of menu */ 
 

 
/* end of header */ 
 

 
/* feature */ 
 

 
#templatemo_feature_wrapper { 
 
    width: 100%; 
 
    height: 266px; 
 
    background: url(images/templatemo_feature_bg.png) repeat-x; 
 
} 
 
#templatemo_feature { 
 
    width: 910px; 
 
    height: 216px; 
 
    padding: 40px 15px; 
 
    margin: 0 auto; 
 
    color: #fff; 
 
} 
 
#feature_left { 
 
    float: left; 
 
    width: 440px; 
 
} 
 
#feature_left p { 
 
    text-align: justify; 
 
} 
 
#feature_right { 
 
    float: right; 
 
    width: 400px; 
 
} 
 
#feature_right #feature_image { 
 
    position: relative; 
 
    width: 400px; 
 
    height: 173px; 
 
    padding: 10px; 
 
} 
 
#feature_right #feature_image span { 
 
    position: absolute; 
 
    top: 0; 
 
    left: 0; 
 
    width: 420px; 
 
    height: 193px; 
 
    background: url(images/template_feature_image.png) no-repeat; 
 
} 
 
/* end of feature */ 
 

 
#templatemo_content_wrapper { 
 
    width: 900px; 
 
    margin: 0 auto; 
 
    padding: 30px 15px; 
 
} 
 
#templatemo_content { 
 
    float: left; 
 
    width: 660px; 
 
} 
 
#templatemo_sidebar { 
 
    float: right; 
 
    width: 200px; 
 
    padding: 0px 0px; 
 
} 
 
.col_w200 { 
 
    width: 150px; 
 
    padding: 30px; 
 
} 
 
#gallery img:hover { 
 
    -webkit-transform: scale(1.5); 
 
    /*Webkit: increase size to 1.5x*/ 
 
    opacity: 1; 
 
    /*default opacity*/ 
 
    z-index: 10; 
 
    /*place hover image in front the non-hover images*/ 
 
} 
 
.templatemo_menu { 
 
    position: relative; 
 
    display: inherit; 
 
} 
 
.dropdown-content { 
 
    display: none; 
 
    position: absolute; 
 
    background-color: #f9f9f9; 
 
    min-width: 160px; 
 
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); 
 
} 
 
.dropdown-content a { 
 
    color: black; 
 
    padding: 12px 16px; 
 
    text-decoration: none; 
 
    display: block; 
 
} 
 
.dropdown-content a:hover { 
 
    background-color: #fff 
 
} 
 
.templatemo_menu .dropdown-content { 
 
    display: none; 
 
} 
 
.templatemo_menu:hover .dropdown-content { 
 
    display: block; 
 
} 
 
.dropdown:hover .dropbtn { 
 
    background-color: #3e8e41; 
 
}
<div id="templatemo_menu"> 
 
    <ul> 
 
    <li><a href="#" class="current">Home</a></li> 
 
    <li class="templatemo_menu"><a href="Aboutus.html" class="dropbtn">Coindia</a> 
 
     <div class="dropdown-content"> <a href="#">Link 1</a> <a href="#">Link 2</a> <a href="#">Link 3</a> </div> 
 
    </li> 
 
    <li><a href="http://www.flashmo.com" target="_parent">Services</a></li> 
 
    <li><a href="http://www.koflash.com" target="_parent">Facility</a></li> 
 
    <li><a href="#">Photo Gallery</a></li> 
 
    <li><a href="#">Careers</a></li> 
 
    <li><a href="#">Contact Us</a></li> 
 
    <li><a href="#">News & Events</a></li> 
 
    </ul> 
 
</div> 
 
<!-- end of templatemo_menu -->

回答

0

試試這個代碼,它是一個好例子。

* { margin: 0; padding: 0; } 
 
body { background: #f1f1f1; margin: 50px; } 
 

 
#nav { margin: 0; padding: 0; float: left; } 
 
#nav li { list-style: none; background: #fff; width: 250px; border-bottom: 1px solid #666; } 
 
#nav li a { display: block; padding: 8px; border-left: 4px solid #444; text-decoration: none; box-shadow: 2px 2px 5px #ccc; color: #555; } 
 
#nav li a:hover { border-left: 4px solid #069; background: #f8f8f8; } 
 
#nav li ul { display: none; } 
 
#nav li:hover ul { display: block; } 
 
#nav li:hover ul li { background: #333; } 
 
#nav li:hover ul li a { color: #ccc; } 
 
#nav li:hover ul li a:hover { background: #222; border-left: 4px solid #900; }
\t <ul id="nav" > 
 
\t 
 
\t \t <li><a href="#">Home</a></li> 
 
\t \t <li><a href="#">Sobre Nós</a></li> 
 
\t \t <li><a href="#">Portfólio</a> 
 
\t \t 
 
\t \t \t <ul> 
 
\t \t \t \t <li><a href="#">sub - 1</a></li> 
 
\t \t \t \t <li><a href="#">sub - 2</a></li> 
 
\t \t \t \t <li><a href="#">sub - 3</a></li> 
 
\t \t \t </ul> 
 
\t \t 
 
\t \t </li> 
 
\t \t <li><a href="#">Serviços</a> 
 
\t \t 
 
\t \t \t <ul> 
 
\t \t \t \t <li><a href="#">sub - 1</a></li> 
 
\t \t \t \t <li><a href="#">sub - 2</a></li> 
 
\t \t \t \t <li><a href="#">sub - 3</a></li> 
 
\t \t \t </ul> 
 
\t \t 
 
\t \t </li> 
 
\t \t <li><a href="#">Blog</a></li> 
 
\t \t <li><a href="#">Contato</a></li> 
 
\t 
 
\t </ul>