<head>
<style>
dl,dt,dd{
margin:0;
padding:0;
cursor:pointer;
}
a{
text-decoration: none;
}
dt{
height:30px;
text-align: center;
line-height:30px;
}
#menuBox>dt{
border:1px solid #ccc;
}
#menuBox>dd{
border:1px solid #ccc;
overflow:hidden;
}
</style>
<script>
window.onload=function(){
var y=document.getElementById('y');
var style;
if(y.currentStyle){
style=y.currentStyle;
}else{
style=getComputedStyle(y,false);
}
alert(style.height);
}
</script>
<head>
<body>
<dl id="menuBox">
<dt class="title">基本信息管理</dt>
<dd class="option" id="y">
<dl >
<dt ><a href="" target="">员工信息管理</a></dt>
<dt><a href="" target="">角色信息管理</a></dt>
<dt><a href="" target="">功能信息管理</a></dt>
</dl>
</dd>
<dt class="title">系统管理</dt>
<dd class="option"> <!-- option:选项 -->
<dl>
<dt><a href="" target="">修改密码</a></dt>
<dt><a href="" target="">注销</a></dt>
</dl>
</dd>
</dl>
</body>
执行以上代码,打印结果为auto
说明取到的id为“y”的dd标签高度类型为auto
以前看老师做相同案例的时候,老师这么执行打印结果就是90px
不知道为什么我用了ie和360浏览器执行结果都为auto
有大神知道答案吗?
你360是兼容模式吧,兼容也是ie。firefox,chrome输出90。内核不一样,谷歌返回了实际的高度值,并不是css的,ie的是css默认auto
分析网页,爬虫之类的最好用chrome,其次firefox