为何类:.sa .sbtn .right-menu ul li a 所设置的padding-left:0px不生效?右侧的导航菜单的左边距仍然是延袭了左侧下拉菜单的样式(该样式为左边距padding-left为28px)?
谁帮着看一下啊?辛苦了,多谢哈。
具体见下图的显示:
代码在此:
<!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 charset="UTF-8">
<title>测试页面</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
cursor: pointer;
}
a {
font-family:Microsoft YaHei,Simsun;
}
.sa {
float: left;
margin-top: 121px;
margin-left: 158px;
position: relative;
z-index: 9999;
width: 200px;
height: 500px;
}
.sbtn {
position: relative;
z-index: 10000;
}
.tnavContainer {
display: block;
border:0px solid;
background-color: white;
width:200px;
position:relative;
z-index:10001;
height: 46px;
}
.tnav {
float:right;
width:200px;
position:relative;
z-index:10002;
text-align:center;
border:0px solid;
}
.navHighlight {
border:0px solid;
position: absolute;
z-index:10003;
width:100%;
height:3px;
top:36px;
right:0px;
background-color:#f56400;
}
.sa .sbtn h2 {
font-size: 14px;
font-weigth:400;
font-family:Microsoft YaHei,Simsun;
}
.sa .sbtn h2 a {
line-height: 36px;
background-color: ;
padding-left: 10px;
width: 180px;
padding-right:0px;
text-decoration: none;
height: 36px;
color: #444;
weight: normal;
display: block;
}
.sa .sbtn h2 a:hover {
background-color: ;
}
.sa .sbtn ul {
position: absolute;
z-index: 10000;
width: 210px;
height: 400px;
top: 36px;
left: 0px;
list-style: none;
display: none;
padding-top: 10px;
background-color: #fff;
border:1px solid #e1e3df;
}
.sa .sbtn ul li {
padding-bottom: ;
zoom: 1;
clear: both;
}
.sa .sbtn ul li a {
padding-left: 28px;
font-size: 12px;
margin-top: ;
line-height: 44px;
text-decoration: none;
color: #fff;
white-space: nowrap;
}
.sa .sbtn ul li.active{
background:#feefe5;
}
.sa .sbtn:hover ul {
display: block;
}
.sa .sbtn ul li:hover {
background-color: #feefe5;
}
.sa .sbtn ul li:hover a,.sa .sbtn ul li.active a {
color: #666;
}
.right-menu {
display: none;
width: 800px;
height: 400px;
border:1px solid #e1e3df;
border-right:1px solid #e1e3df;
border-bottom:1px solid #e1e3df;
background-color: #fff;
position: absolute;
top: 0px;
left: 210px;
}
.sa .sbtn .right-menu ul li a {
padding-left:0px;
}
.s1>div{
position: absolute;
left: 210px;
width: 800px;
}
.show{
display:block;
}
</style>
</head>
<body>
<div class="sa">
<div class="sbtn">
<div class="tnavContainer">
<div class="tnav">
<h2><a href="#">商品目录</a></h2>
<p class="navHighlight">
</p>
</div>
</div>
<ul>
<li class="s1 active"><a href="#">女装</a>
<div class="right-menu show">
<dl>
<dd>
<a href="#">针织衫</a>
<a href="#">T恤</a>
<a href="#">毛衣</a>
<a href="#">衬衫</a>
<a href="#">半身裙</a>
<a href="#">长裙</a>
<a href="#">短裙</a>
<a href="#">风衣</a>
<a href="#">卫衣</a>
<a href="#">短外套</a>
<a href="#">夹克</a>
<a href="#">裤子</a>
<a href="#">西装</a>
<a href="#">大码女装</a>
<a href="#">妈妈装</a>
<a href="#">旗袍</a>
<a href="#">唐装</a>
<a href="#">休闲裤</a>
<a href="#">阔脚裤</a>
<a href="#">牛仔裤</a>
<a href="#">短裤</a>
<a href="#">打底衫</a>
<a href="#">打底裤</a>
<a href="#">吊带</a>
<a href="#">内衣</a>
<a href="#">皮衣</a>
<a href="#">皮草</a>
<a href="#">礼服</a>
<a href="#">舞台装</a>
<a href="#">套装</a>
</dd>
</dl>
</div>
</li>
<li class="s1">
<a href="#">男装</a>
<div class="right-menu">
<dl>
<dd>
C
</dd>
</dl>
</div>
</li>
<li class="s1"><a href="#">男鞋</a>
<div class="right-menu">
<dl>
<dd>
D
</dd>
</dl>
</div>
</li>
</ul>
</div>
</div>
</body>
<script>
window.onload=function(){
var c1 = checkM('.sbtn>ul','.s1>div');
};
var checkMenu= function(box,menu,ev){
this.box = document.querySelector(box);
this.menu = document.querySelectorAll(menu);
this.lis = this.box.children;
this.init();
}
var checkM = function(box,menu){
return new checkMenu(box,menu);
}
checkMenu.prototype={
init:function(){
var me =this,
menu = me.menu,
lis = me.lis,
box = me.box;
box.addEventListener('mouseover',function(e){
e = e||window.event;
var src = e.srcElement||e.target;
if(src!=box){
me.idx = me.getIndex(src,box);
for(var i=0;i<menu.length;i++){
i==me.idx&&(
me.removeCls(menu,'show'),me.addCls(menu[i],'show'),
me.removeCls(lis,'active'),me.addCls(lis[i],'active')
);
}
}
});
box.addEventListener('mouseleave',function(e){
me.removeCls(menu,'show');
me.addCls(menu[0],'show');
me.removeCls(lis,'active');
me.addCls(lis[0],'active');
});
},
addCls:function(el,cls){
el.className = el.className.replace(/\s+$/,'')
el.className += el.className?' '+cls:cls;
},
removeCls:function(el,cls){
if(el.length>0){
for(var i=0;i<el.length;i++){
el[i].className = el[i].className.indexOf(cls)==-1?el[i].className:el
[i].className.replace(new RegExp('\\s?'+cls),'');
}
}
},
getIndex:function(src,lis){
return [].slice.call(lis.children).indexOf(src);
}
}
</script>
</html>