CSS样式对齐
<!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=gb2312" />
<title></title>
<script language="javascript">
function tabChange(obj,id)
{
var arrayli = obj.parentNode.getElementsByTagName("li"); //获取li数组
var arrayul = document.getElementById(id).getElementsByTagName("ul"); //获取ul数组
for(i=0;i<arrayul.length;i++)
{
if(obj==arrayli[i])
{
arrayli[i].className = "cli";
arrayul[i].className = "";
}
else
{
arrayli[i].className = "";
arrayul[i].className = "hidden";
}
}
}
</script>
<style type="text/css">
.tabbox
{
position:absolute;
top:0px;
left:0px;
width:100%;
height:97%;
background:#fff;
}
.tabmenu
{
height:80%;
}
#tabcontent
{
}
.tabmenu ul
{
padding:10% 0% 0% 9%;
list-style-type: none;
}
#tabcontent ul
{
margin:0;
padding:5px;
list-style-type: none;
}
.tabmenu li
{
text-align:center;
float:left;
display:block;
width:22%;
height:450px;
line-height:450px;
overflow:hidden;
background:#d90202;
border-left:#ccc 1px solid;
border-right:#ccc 1px solid;
border-bottom:#ccc 2px solid;
display:inline;
font-size:12px;
}
.tabmenu .cli
{
text-align:center;
float:left;
display:block;
width:22%;
height:450px;
line-height:450px;
overflow:hidden;
background:#2ad902;
border-top: 1px solid rgb(31, 84,188);
border-left: 1px solid rgb(31, 84, 188);
border-right: 1px solid rgb(31, 84, 188);
border-bottom: 2px solid rgb(31, 84, 188);
display:inline;
font-size:12px;
/*cursor:pointer;*/
}
#tabcontent .hidden
{
display:none;
}
body
{
background:#2626F0;
}
</style>
</head>
<body>
<div class = "tabbox">
<div class="tabmenu">
<ul>
<li onmouseup="tabChange(this,'tabcontent')" class="cli"></li>
<li onmouseup="tabChange(this,'tabcontent')"></li>
<li onmouseup="tabChange(this,'tabcontent')"></li>
<li onmouseup="tabChange(this,'tabcontent')"></li>
</ul>
</div>
<div id="tabcontent">
<ul name="tabul">
</ul>
<ul class="hidden">
</ul>
<ul class="hidden">
</ul>
<ul class="hidden">
</ul>
<ul class="hidden">
</ul>
</div>
</div>
</body>
</html>
大家帮忙看看,要怎么办,我样把 .tabmenu .cli 和 .tabmenu li 的高度也用90%来显示,可是会越来越小,用px就不会,这要怎么解决?
我想让tab全屏显示,用百分比显示!请大家帮我改改代码 没听懂你说的意思,这个是我摸索你的意思改的,你看看对不?
<!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=gb2312" />
<title></title>
<script language="javascript">
function tabChange(obj,id)
{
var arrayli = obj.parentNode.getElementsByTagName("li"); //获取li数组
var arrayul = document.getElementById(id).getElementsByTagName("ul"); //获取ul数组
for(i=0;i<arrayul.length;i++)
{
if(obj==arrayli)
{
arrayli.className = "cli";
arrayul.className = "";
}
else
{
arrayli.className = "";
arrayul.className = "hidden";
}
}
}
</script>
<style type="text/css">
body{ height:768px; background:#2626F0;}
.tabbox{top:0px;left:0px;width:100%;height:100%;}
.tabmenu{height:80%;}
.tabmenu ul{ height:100%;}
#tabcontent ul { margin:0;padding:5px;list-style-type: none;}
.tabmenu ul li{text-align:center; float:left;display:block;width:22%; height:90%;overflow:hidden;background:#d90202;border-left:#ccc 1px solid;border-right:#ccc 1px solid; border-bottom:#ccc 2px solid;font-size:12px;}
.tabmenu ul .cli{text-align:center;float:left;display:block;width:22%;height:90%;overflow:hidden;background:#2ad902;border: 1px solid rgb(31, 84,188);border-bottom: 2px solid rgb(31, 84, 188);display:inline;font-size:12px; /*cursor:pointer;*/}
#tabcontent .hidden{display:none;}
</style>
</head>
<body>
<div class = "tabbox">
<div class="tabmenu">
<ul>
<li class="cli">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
<div id="tabcontent">
<ul name="tabul">
</ul>
<ul class="hidden">
</ul>
<ul class="hidden">
</ul>
<ul class="hidden">
</ul>
</div>
</div>
</body>
</html>
页:
[1]