2011年8月3日 星期三

li子層 寬度 比父層 寬 時不要設定overflow: hidden;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
<script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
<style>
* {
    margin:0px;
    padding:0px;
    list-style-position:none;
    list-style-type:none;
    float:none;
}
#content {
    width:500px;
}
#content ul{
    width:500px;
}
.level1{
    width:80px;
    float:left;
    list-style-type: none;
}
.bg{
    width:50px;
}
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
.level1 {
    background-color: #FC0;   
}
.level2 li {
    width:150px;
    background-color: #000;   
    color:#fff;
}
</style>
</head>
<body>
<div id="content">
<ul class="menu">
        <li class="level1"><div class="bg"><a href="">work</a></div>
            <ul class="level2">
                <li>aaa</li>
                <li>bbb</li>
                <li>ccc</li>          
            </ul>
        </li>
         <li class="level1"><div class="bg"><a href="">news</a></div>
            <ul class="level2">
                <li>aaa</li>
                <li>bbb</li>
                <li>ccc</li>          
            </ul>
        </li>  
    </ul>
</div>
</body>
<script language="javascript">
$(document).ready(function(){
$('.level1').hover(function() {
    //$('#work ul').slideDown('slow');
    $(this).children('.level2').show();
},
function(){
//$('#work ul').slideUp('slow');
    $(this).children('.level2').hide();
}
)
/*
); */
})
</script>
</html>

///overflow: hidden; 取消這個即可

沒有留言:

張貼留言