简体   繁体   English

子列表父级中的CSS菜单布局

[英]CSS Menu Layout in Sub-List Parent

I have been using my free time to improve my HTML knowledge during my holiday. 我在假期期间一直在利用空闲时间来改善HTML知识。

During the time I was designing a CSS Menu. 在此期间,我正在设计CSS菜单。 I face some problem and don't know how to solve them. 我遇到一些问题,不知道如何解决。

I tried to search from Google. 我试图从Google搜索。 Because of my poor English, I was unable to find a solution, so I seek help here. 由于我的英语不好,我无法找到解决方案,所以我在这里寻求帮助。

Problem: 问题:

I tried to design a CSS Menu with Expandable sub-menu. 我试图设计带有可扩展子菜单的CSS菜单。 Why doesn't the sub-menu's parent list change? 子菜单的父列表为什么没有更改?

As you can see from the screenshot. 从屏幕截图中可以看到。 The Product menu is different with others. 产品菜单与其他菜单不同。

Is there any solution? 有什么解决办法吗?

ScreenShot 屏幕截图

Due to my reputation I can't provide a screenshot, so I'll provide a link: 由于我的声誉,我无法提供屏幕截图,因此我将提供一个链接:

http://i151.photobucket.com/albums/s155/HongJaiz/CSSMenu.jpg http://i151.photobucket.com/albums/s155/HongJaiz/CSSMenu.jpg

CSS3 Coding CSS3编码

body{
    position: relative;
    height: 100%;
    background: -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#fff));

}

.navbox {
    position: relative;
    float: left;
}

ul#expList {
    list-style: none;
    display: block;
    width: 200px;
    position: relative;
    padding: 60px 0 60px 0;
    background: url(shad2.png) no-repeat;
    -webkit-background-size: 50% 100%;
}

li#expList {
    list-style: none;
    display: block;
    width: 200px;
    position: relative;
    padding: 60px 0 60px 0;
    background: url(shad2.png) no-repeat;
    -webkit-background-size: 50% 100%;
}

ul li {
    list-style: none;
}

li {
    margin: 5px 0 0 0;
}

ul#expList li a {
    -webkit-transition: all 0.3s ease-out;
    background: #cbcbcb url(border.png) no-repeat;
    color: #174867;
    padding: 7px 15px 7px 15px;
    -webkit-border-top-right-radius: 10px;
    -webkit-border-bottom-right-radius: 10px;
    width: 100px;
    display: block;
    text-decoration: none;
    -webkit-box-shadow: 2px 2px 4px #888;
}

ul#expList li a:hover {
    background: #ebebeb url(border.png) no-repeat;
    color: #67a5cd;
    padding: 7px 15px 7px 30px;
}

HTML Coding HTML编码

<ul id="expList">
    <li class="home"><a href="">Home</a></li>
    <li class="freebies">Product
        <ul>
            <li><a href="">List 1</a></li>
            <li><a href="">List 2</a></li>
            <li><a href="">List 3</a></li>
        </ul>
    </li>
    <li class="about"><a href="">Register</a></li>
    <li class="about"><a href="">About Us</a></li>
</ul>

just coz you have given style to <a></a> of <li></li> and in case of parent of submenu ie Product you haven't wrapped it in <a></a> tag, doing so will solve your problem 只是因为您已将样式赋予<li></li> <a></a> ,并且在子菜单(即Product的父级的情况下,尚未将其包装在<a></a>标记中,因此解决你的问题

<ul id="expList">
    <li class="home"><a href="">Home</a></li>
    <li class="freebies"><a>Product</a>
        <ul>
            <li><a href="">List 1</a></li>
            <li><a href="">List 2</a></li>
            <li><a href="">List 3</a></li>
        </ul>
    </li>
    <li class="about"><a href="">Register</a></li>
    <li class="about"><a href="">About Us</a></li>
</ul>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM