如何将子菜单添加到下拉菜单?

时间:2015-06-07 10:39:37

标签: html css drop-down-menu menu submenu

我在下拉菜单中添加子菜单非常困难,但我不是css的专业人士。我想在下拉“项目”中将“10ºao”和“11ºao”部分放在子菜单上,但我所做的一切都不起作用!当放置光标时,如何放置子菜单并在右侧打开?

---------------------------------------这是HTML ---- ---------------------

    <div class="menu-wrap">
    <nav class="menu">
        <ul class="clearfix">
            <li><a href="#">Sobre mim</a></li>
             <li><a href="#">Sobre o curso</a></li>
            <li>
                <a href="#">Projectos <span class="arrow">&#9660;</span></a>

                <ul class="sub-menu">
                    <li><a href="#">10&#8728;  Ano <span class="arrow">&#9654; </span> </a></li>

</li>


                   <li><a href="#">11&#8728;  Ano <span class="arrow">&#9654; </span>  </a>

             <ul>


        </ul>
 </li>

        </li>

                </ul>
            </li>
            <li><a href="#">Contactos</a></li> 

        </ul>
    </nav>
</div>

----------------------------------------------- ---这里是css ----------------------------------

    <style>
<!-- cor rosa #be5b70 -->

.clearfix:after {
    display:block;
    clear:both;


}

/*----- Menu Outline -----*/

.menu-wrap {
    width:100%;
    box-shadow:0px 1px 3px rgba(0,0,0,0.2);
    background:#3e3436;


}

.menu {
    width:1000px;
    margin:0px auto;

}

.menu li {
    margin:0px;
    list-style:none;
    font-family:'Ek Mukta';


}

.menu a {
    transition:all linear 0.15s;
    color:#919191;



}

.menu li:hover > a, .menu .current-item > a {
    text-decoration:none;
    color:#be5b70;


}

.menu .arrow {
    font-size:11px;
    line-height:0%;

}

/*----- Top Level -----*/
.menu > ul > li {
    float:left;
    display:inline-block;
    position:relative;
    font-size:19px;

}

.menu > ul > li > a {
    padding:10px 40px;
    display:inline-block;
    text-shadow:0px 1px 0px rgba(0,0,0,0.4);




}

.menu > ul > li:hover > a, .menu > ul > .current-item > a {
    background:#3e3436;
    border-radius: 10px; 

}

/*----- Bottom Level -----*/
.menu li:hover .sub-menu {
    z-index:1;
    opacity:1;

}

.sub-menu {
    width:130%;
    text-align: center;
    padding:5px 0px;
    position:absolute;
    top:100%;
    left:0px;
    z-index:-1;
    opacity:0;
    transition:opacity linear 0.15s;
    box-shadow:0px 2px 3px rgba(0,0,0,0.2);
    background:#2e2728;
    border-radius: 10px; 

}

.sub-menu li {
    display:block;
    font-size:16px;



}

.sub-menu li a {
    padding:10px 7px;
    display:block;

}

.sub-menu li a:hover, .sub-menu .current-item a {
    background:#3e3436;
    border-radius: 10px;                


}

.sub-menu li:hover > a, .menu .current-item > a {
    text-decoration: none;
    color:#E68268;

    <!-- lalalalalalal separador-->


li.sub-menu li {
display:none;
position: absolute; left: 100%; top:0;}

li.sub-menu:hover li{
display: block;}


</style>

1 个答案:

答案 0 :(得分:0)

<!-- cor rosa #be5b70 --> .clearfix:after {
    display:block;
    clear:both;
}
/*----- Menu Outline -----*/
 .menu-wrap {
    width:100%;
    box-shadow:0px 1px 3px rgba(0, 0, 0, 0.2);
    background:#3e3436;
}
.menu {
    width:1000px;
    margin:0px auto;
}
.menu li {
    margin:0px;
    list-style:none;
    font-family:'Ek Mukta';
}
.menu a {
    transition:all linear 0.15s;
    color:#919191;
}
.menu li:hover > a, .menu .current-item > a {
    text-decoration:none;
    color:#be5b70;
}
.menu .arrow {
    font-size:11px;
    line-height:0%;
}
/*----- Top Level -----*/
 .menu > ul > li {
    float:left;
    display:inline-block;
    position:relative;
    font-size:19px;
}
.menu > ul > li > a {
    padding:10px 40px;
    display:inline-block;
    text-shadow:0px 1px 0px rgba(0, 0, 0, 0.4);
}
.menu > ul > li:hover > a, .menu > ul > .current-item > a {
    background:#3e3436;
    border-radius: 10px;
}
/*----- Bottom Level -----*/
 .menu li:hover .sub-menu {
    z-index:1;
    opacity:1;
}
.sub-menu {
    width:130%;
    text-align: center;
    padding:5px 0px;
    position:absolute;
    top:100%;
    left:0px;
    z-index: -1;
    opacity:0;
    transition:opacity linear 0.15s;
    box-shadow:0px 2px 3px rgba(0, 0, 0, 0.2);
    background:#2e2728;
    border-radius: 10px;
}
.sub-menu li {
    display:block;
    font-size:16px;
    position: relative;
}
.sub-menu li a {
    padding:10px 7px;
    display:block;
}
.sub-menu li a:hover, .sub-menu .current-item a {
    background:#3e3436;
    border-radius: 10px;
}
.sub-menu li:hover a, .menu .current-item a {
    text-decoration: none;
    color:#E68268;
}
/* li.sub-menu li {
        display:none;
        position: absolute;
        left: 100%;
        top:0;
    }
    li.sub-menu:hover li {
        display: block;
    }*/
 .sub-menu li ul {
    display: none;
}
.sub-menu li:hover ul {
    display: block;
    width: 100%;
    position: absolute;
    left: 100%;
    top: 0;
    text-align: center;
    padding:5px 0px;
    transition:opacity linear 0.15s;
    box-shadow:0px 2px 3px rgba(0, 0, 0, 0.2);
    background:#2e2728;
    border-radius: 10px;
}
<div class="menu-wrap">
    <nav class="menu">
        <ul class="clearfix">
            <li><a href="#">Sobre mim</a></li>
            <li><a href="#">Sobre o curso</a></li>
            <li><a href="#">
                Projectos <span class="arrow">&#9660;</span></a>

                <ul class="sub-menu">
                    <li><a href="#">10&#8728;  Ano <span class="arrow">&#9654; </span> </a>                        
                         <ul>
                            <li><a href="#">1Ano </a></li>
                            <li><a href="#">1Ano </a></li>
                        </ul>
                    </li>
                    <li><a href="#">11&#8728;  Ano <span class="arrow">&#9654; </span>  </a>
                 <ul>
                            <li><a href="#">1Ano </a></li>
                            <li><a href="#">1Ano </a></li>
                        </ul>                      
            </li>
                </ul>
            </li>            
             <li><a href="#">Contactos</a>

            </li>   
        </ul>
    </nav>
</div>