整个页面的大div的height值用百分比,可行不?

天降大任于斯 2008-04-15 12:13:13
页面有三块,左边两块右边一块
我设为: 左边宽度都为70%,右边为30%
左边高度各50%,右边100%

我的目的是用户控制浏览器大小的时候同比例缩放这几个div,这样做可行不?还是要js控制?
...全文
390 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
knowledge_Is_Life 2008-05-01
  • 打赏
  • 举报
回复
都是很好的建议! 值得学习
ddcatlee 2008-04-15
  • 打赏
  • 举报
回复
<!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>
<style type="text/css">
<!--
* {
margin:0;
padding:0;
}
html,
body {
height:100%;
}
#sub1,
#sub2 {
background:#FFC;
float:left;
clear:left;
width:30%;
height:50%;
}
#sub1 {
background:#CF9;
}
#main {
background:#CFF;
margin-left:30%;
height:100%;
}
* html #main {
margin:0;
float:left;
width:69.9%;
}
-->
</style>
</head>

<body>
<div id="sub1">sub1</div>
<div id="sub2">sub2</div>
<div id="main">main</div>
</body>
</html>


3个层不能有margin和padding,body也不可有,否则会有滚动条
天降大任于斯 2008-04-15
  • 打赏
  • 举报
回复
嘿嘿,是这样的,这样符合规范么?
在IE下是可以的,但在火狐下不行,有滚动条出现,不知道为什么
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="./index.css" />
</head>
<body>
<div class="content">
<div class="left">
<div id="public_msg"></div>
<div id="private_msg"></div>
</div>
<div class="right"></div>
</div>
</body>
</html>[code]


[code=CSS]
body{
border:0px;
padding:0px;
margin:0px;
}
.content{
width:100%;
height:100%;
border:#0000FF dashed;
padding:0px;
clear:both;
}
.left{
width:70%;
height:100%;
border:#FF0000 dashed;
float:left;
}
.right{
width:20%;
height:100%;
border:#00FF00 thin;
float:right;
}
#public_msg{
width: 100%;
height:50%;
overflow:scroll;
border:#FF0000 solid;
}

#private_msg{
width:100%;
height:30%;
border:#FF0000 solid;
}



zl_c 2008-04-15
  • 打赏
  • 举报
回复
没看懂.
"页面分为左右两块,左70%,右30%,左边再分为上下两块,高度各占50%",是这样的吗?

61,124

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧