Home > Web Front-end > HTML Tutorial > 二级菜单不能顶头_html/css_WEB-ITnose

二级菜单不能顶头_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:32:45
Original
1278 people have browsed it

<!DOCTYPE html ><html><head>    <title></title>    <style >    #menu,#submenu{ font-family:微软雅黑; font-size:medium;}/*菜单字体*/       #menu{width:100%}    #menu ul,#submenu ul{ list-style:none;} /*去掉列表的点*/     #menu ul li,#submenu ul li{ float:left; padding:10px; width:120px; text-align:center}/*横向显示*/     #submenu{ text-align:left; display: block; position: inherit;}    #menu ul li:hover{ border-bottom-style:solid; border-bottom-color:rgba(0,0,255,.5); cursor:pointer; color:rgba(255,0,0,.5);}    #menu ul li:active{border-bottom-style:none; border-bottom-color:Red;cursor:pointer;color:Red;}    .subfirst{ float:left; display:none;}    </style>    <script src="jquery.2.1.4.min.js" type="text/javascript"></script>    <script type="text/javascript">        function showsub(rootid) {            hidesub();            $('#submenu' + rootid).show();        }        function hidesub() {            for (var i = 1; i <= 3; i++) {                $('#submenu' + i).hide();            }        }    </script></head><body>    <div id="menu">    <ul>    <li id="menu1" onmouseover="showsub(1)";">根菜单一</li>    <li id="menu2" onmouseover="showsub(2)";">根菜单二</li>    <li id="menu3" onmouseover="showsub(3)";">根菜单三</li>    </ul>    </div>    <div id="submenu">    <ul id="submenu1" class="subfirst">    <li id="menu11">二级菜单1-1</li>    <li id="menu12">二级菜单1-2</li>    <li id="menu13">二级菜单1-3</li>    </ul>    <ul id="submenu2" class="subfirst">    <li id="menu21">二级菜单2-1</li>    <li id="menu22">二级菜单2-2</li>    <li id="menu23">二级菜单2-3</li>    </ul>    <ul id="submenu3" class="subfirst">    <li id="menu31">二级菜单3-1</li>    <li id="menu32">二级菜单3-2</li>    <li id="menu33">二级菜单3-3</li>    </ul>    </div></body></html>
Copy after login


二级菜单不能顶头是什么没有设置好,设置了div百分百的宽度,还是接着后面显示了


想让二级菜单换行显示,CSS怎么控制


回复讨论(解决方案)

#submenu{ text-align:left; display: block; position: inherit;clear: both;}

可以使用绝对布局position:absloute
然后设置left,top等

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template