儿童元素不起作用

时间:2014-10-09 09:58:23

标签: html css navbar

嗨,我只是想知道如何将我的孩子元素置于父母元素之下?在navmenu感谢 http://jsfiddle.net/5xs0Lyu2/

<html>
<head>
<script type="text/javascript">

 </script>
 <title>
 Sample Website
</title>
<style>
ul#navmenu, ul.sub1, ul.sub2 {
    list-style-type: none;
    font-size: 9pt;
    }

.li1 {
    width: 125px;
    text-align: center;
    position: relative;
    float: left;
    margin-right: 0px;
    }

    ul#navmenu {
    width: 641px;
    margin: 0px auto;
    }

ul#navmenu a {
    text-decoration: none;
    display: block;
    width: 125px;
    height: 25px;
    line-height: 25px;
    background-color: orange;
    color: #000;
    }

ul#navmenu .sub1 li {
    }

ul#navmenu .sub1 a {
    margin-top: 5px;
    }

ul#navmenu .sub2 a {
    margin-left: 3px;
    }

ul#navmenu li:hover > a {
    background-color: grey;
    }

ul#navmenu li:hover a:hover {
    background-color: red;
    }

ul#navmenu ul.sub1 {
    display: none;
    position: absolute;
    top: 25px;
    right: 00px;
    }

ul#navmenu ul.sub2 {
    display: none;
    position: absolute;
    top: 0px;
    left: 126px;
    }

ul#navmenu li:hover .sub1 {
    display: block;
    }

ul#navmenu .sub1 li:hover .sub2 {
    display: block;
    }

.darrow {
    font-size: 11pt;
    position: absolute;
    top: 5px;
    right: 4px;
    }

.rarrow {
    font-size: 13pt;
    position: absolute;
    top: 6px;
    right: 4px;
    }
    body
{
margin-bottom:50px;
}
#footer
{
background-color: red;
position: fixed;
bottom: 0px;
left: 0px;
right: 0px;
height: 50px;
margin-bottom: 0px;

}
#header
{
background-color: red;
position: fixed;
width: 100%;
height: 50px;
z-index: 2;
}
*{
margin: 0px;
border: 0px;
padding: 0px;
spacing: 0px;
}
.li2 {
    width: 125px;
    text-align: center;
    position: relative;
    float: left;
    margin-right: 0px;
    }
</style>
</head>
<body>
<div style="z-index: 3;">
<div id="header">
header
</div><br><br><br>



<ul id="navmenu">
<li class="li1"><a href="#">hyperlink 1</a></li>
<li><a href="#" class="li1">hyperlink 2</a><span class="darrow">&#9660;</span>
    <ul class="sub1">
        <li><a href="#">hyperlink 2.1</a></li>
        <li><a href="#">hyperlink 2.2</a></li>
        <li><a href="#">hyperlink 2.3</a></li>
    </ul>
</li>
<li class="li1"><a href="#">hyperlink 3</a></li>
<li class="li1"><a href="#">hyperlink 4</a><span class="darrow">&#9660;</span>
    <ul class="sub1">
        <li><a href="#">hyperlink 4.1</a></li>
        <li><a href="#">hyperlink 4.2</a></li>
        <li><a href="#">hyperlink 4.3</a><span class="rarrow">&#9654;</span>
            <ul class="sub2">
                <li><a href="#">hyperlink 4.3.1</a></li>
                <li><a href="#">hyperlink 4.3.2</a></li>
                <li><a href="#">hyperlink 4.3.3</a></li>
            </ul>
        </li>
    </ul>
</li>
<li class="li2"><a href="#">hyperlink 5</a></li>
</ul>






















</div>
<div id="footer">
Footer
</div>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

除非你关闭

,否则你的小提琴不会奏效
<title> 

选中此http://jsfiddle.net/5xs0Lyu2/6/

首先,我在下拉列表中添加了一个ID,然后将其添加到css

#subclass{
margin-top:50px;
margin-right:120px;
}

http://jsfiddle.net/5xs0Lyu2/8/