如何将子菜单添加到下拉菜单 [英] how to Add sub menu to dropdown menu

查看:132
本文介绍了如何将子菜单添加到下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加子菜单到这个下拉功能,但我没有什么知识的CSS,我没有得到如何做到这一点。我想要将子菜单打开到右侧,当光标放在它上面时是与它相关的css和html

I want to add sub-menu to this drop down function,but i have little knowledge of css , i am not getting how to do this. i want the sub-menu open to right side when cursor is placed on it Here is the css and html relating to it

CSS

ul.dark_menu {
    list-style: none;
    padding: 5px 1px;
    font-family:'Segoe UI Light', 'Open Sans', Verdana, Arial, Helvetica, sans-serif;
    font-weight: 200;
    font-size: 16px;
    letter-spacing: 0.01em;
    font-smooth: always;
    color: #000000;
    line-height: 15px;
    margin: auto;
    width: 1018px;
    position: relative;
    background: #2B5797;
}
/* Blog johanes djogzs.blogspot.com */
 ul.dark_menu:after {
    content:"";
    clear: both;
    display: block;
    overflow: hidden;
    visibility: hidden;
    width: 0;
    height: 0;
}
ul.dark_menu li {
    float: left;
    position: relative;
    margin: 1px;
}
/* Blog johanes djogzs.blogspot.com */
 ul.dark_menu li a, ul.dark_menu li a:link {
    color: #fafafa;
    text-decoration: none;
    display: block;
    padding: 8px 26px;
    -webkit-transition: all 0.2s ease;
    -moz-transition: all 0.2s ease;
    -o-transition: all 0.2s ease;
    -ms-transition: all 0.2s ease;
    transition: all 0.2s ease;
}
/* Blog johanes djogzs.blogspot.com */
 ul.dark_menu li a:hover {
    color: #fafafa;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
}
/* Blog johanes djogzs.blogspot.com */
 ul.dark_menu li a.selected {
    border-right: 1px solid #ddd;
    text-transform: uppercase;
    margin-left: 10px;
}
ul.dark_menu li a.selected, ul.dark_menu li a:active {
    color: #fafafa;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
}
ul.dark_menu li ul {
    display: none;
}
/* Blog johanes djogzs.blogspot.com */
 ul.dark_menu li ul:before {
    content:" ";
    position: absolute;
    display: block;
    z-index: 1500;
    left: 0;
    top: -10px;
    height: 10px;
    width: 100%;
}
ul.dark_menu li ul {
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
    top:55px;
}
ul.dark_menu li:hover ul {
    position: absolute;
    display: block;
    z-index: 1000;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
    left: 0;
    border-radius: 0px 0px 5px 5px;
    top: 37px;
    padding: 5px 0;
    list-style: none;
    background: #fff;
}
/* Blog johanes djogzs.blogspot.com */
 ul.dark_menu li ul li {
    float: none;
    margin:0px;
}
ul.dark_menu li ul li:first-child {
    margin:0px;
    border-top: 0 none;
}
ul.dark_menu li ul li:last-child {
    border-bottom: 0 none;
}
/* Blog johanes djogzs.blogspot.com */
 ul.dark_menu[data-role="dropdown"] > a::before {
    position: absolute;
    content:"^";
    display: block;
    font-size: 15px;
    left: 100%;
    margin-left: -20px;
    top: 10px;
    -webkit-transform: rotate(180deg);
    -moz-transform: rotate(180deg);
    -ms-transform: rotate(180deg);
    -o-transform: rotate(180deg);
    transform: rotate(180deg);
}
ul.dark_menu li ul li a, ul.dark_menu li ul li a:link {
    color: #222;
    display: block;
    background: transparent none;
    padding: 10px 25px 10px 25px;
    white-space: nowrap;
}
ul.dark_menu li ul li a:hover {
    background:#2D89EF;
    -moz-transition: all 0.1s ease-in-out;
    color:#fff;
    -webkit-transition: all 0.1s ease-in-out;
}
/* Blog johanes djogzs.blogspot.com */
 .menujohanes {
    position:relative;
}
#search input[type="text"]:hover {
    width:848px;
}
#search input[type="text"] {
    background: #fff url("http://3.bp.blogspot.com/-uYZni0pIn-E/T-xY2vVu_-I/AAAAAAAACUY/ZMfR3_BvRFE/s1600/SEARCH_32x32-32.png")no-repeat center left;
    font-size: 13px;
    color: #222;
    width: 0px;
    padding: 10px 0px 11px 35px;
    z-index: 9;
    border: 1px solid #fff;
    -webkit-transition: all 0.5s ease-in-out;
    -moz-transition: all 0.5s ease-in-out;
    margin-bottom: -1px;
    position: absolute;
    top: 0px;
    right:27px;
}
#main4, #main5, #main6 {
    width: 303px;
    list-style-type: none;
    float: left;
    margin: 10px;
}
.main3 {
    width:305px;
    list-style-type: none;
    padding-top: 10px;
    float: left;
}
::-webkit-scrollbar {
    height:12px;
    background: #474747;
}
::-webkit-scrollbar-thumb {
    background-color: #000;
}

HTML

<div class='menujohanes'>
        <ul class='dark_menu'>
          <li>
            <a class='selected' expr:href='data:blog.homepageUrl' title='Home'>
              Home
            </a>
          </li>

       <li data-role='dropdown'>
            <a href='#'>
              Categories
            </a>
            <ul>
                 <li>
                    <a href='#'>
                    Lorem ipsum
                    </a>
                </li>

               <li>
                <a href='#'>
                  Lorem ipsum
                </a>
              </li>
              <li>
                <a href='#'>
                  Lorem ipsum
                </a>
              </li>
              <li>
                <a href='#'>
                  Lorem ipsum
                </a>
              </li>
              <li>
                <a href='#'>
                  Download
                </a>
              </li>
              <li>
                <a href='#'>
                  Lorem ipsum
                </a>
              </li>
            </ul>
          </li>
        </ul>
        <form action='/search' id='search' method='get'>
          <input name='q' placeholder='Search Somethings..' size='40' type='text'/>
        </form>
      </div>

请帮助,因为我通过Google搜索,但没有理解如何包括子菜单

Please help as I did search over Google for it but didn't understood how to include sub-menu into this.

谢谢

推荐答案

尝试这个

 <li class='sub'>
     <a href='#'>Lorem ipsum </a>
        <ul>
           <li>
             <a href='#'>
                sub-item 1
               </a>
            </li>
        </ul>
 </li>

并在css中添加此

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

li.sub:hover ul{
display: block;}

为了创建新的子菜单,只需将class ='sub'添加到<并添加新的< ul>作为一个孩子。
示例: http://jsfiddle.net/6kDG8/2/

For creating new sub menus just add class='sub' to the < li> and add new < ul> below it as a child . Example: http://jsfiddle.net/6kDG8/2/

这篇关于如何将子菜单添加到下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆