二列左列宽度固定,右列宽度自适应布局
2009-09-25 18:01
218 查看
<!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 language="javascript" type="text/javascript">
var div2Width;
window.onload=function (){
div2Width=document.getElementById("div2")
div2Width.style.width=(document.body.clientWidth-250)+"px"
}
window.onresize=function(){
div2Width.style.width=(document.body.clientWidth-250)+"px"
}
</script>
<style type="text/css">
<!--
body,div,html { height:100%;margin:0px; padding:0px; }
-->
</style>
</head>
<body>
<div style="width:100%">
<div style="height:100%; width:250px; background:#CCDEFD; float:left">
<p>左边固定值,右边百分比占完整屏幕的方法。</p>
<p>1、用table当然很简单了,左边td固定值,右边100%就ok了</p>
<p>2、div就不知道咋弄了,右边100%肯定不能float到一行上去了。只好用js判断浏览器的宽度然后减去左边的宽度。</p>
<p>3、不知道有没有更好的解决办法。</p>
</div>
<div style="height:100%; background:#F2F2F2; float:left" id="div2">2</div>
</div>
</body>
</html>
<!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" xml:lang="zh-CN" lang="zh-CN">
<head>
<title>利用haslayout</title>
<style type="text/css">
#left
{float:left;width:100px;height:100px;background-color:#ccc;border:2px solid #333;
}
#right
{overflow:hidden;zoom:1; border:2px solid #333;background:#ccc url(http://www.baidu.com/img/baidu_logo.gif) no-repeat;
}
</style>
</head>
<body>
<div id="left"> left </div>
<div id="right"> 1111<br />1111<br />1111<br />1111<br />1111<br />1111<br />111<br />11</div>
</body>
</html>
这里有几种方法
http://www.cssass.com/blog/index.php/2008/31.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
var div2Width;
window.onload=function (){
div2Width=document.getElementById("div2")
div2Width.style.width=(document.body.clientWidth-250)+"px"
}
window.onresize=function(){
div2Width.style.width=(document.body.clientWidth-250)+"px"
}
</script>
<style type="text/css">
<!--
body,div,html { height:100%;margin:0px; padding:0px; }
-->
</style>
</head>
<body>
<div style="width:100%">
<div style="height:100%; width:250px; background:#CCDEFD; float:left">
<p>左边固定值,右边百分比占完整屏幕的方法。</p>
<p>1、用table当然很简单了,左边td固定值,右边100%就ok了</p>
<p>2、div就不知道咋弄了,右边100%肯定不能float到一行上去了。只好用js判断浏览器的宽度然后减去左边的宽度。</p>
<p>3、不知道有没有更好的解决办法。</p>
</div>
<div style="height:100%; background:#F2F2F2; float:left" id="div2">2</div>
</div>
</body>
</html>
<!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" xml:lang="zh-CN" lang="zh-CN">
<head>
<title>利用haslayout</title>
<style type="text/css">
#left
{float:left;width:100px;height:100px;background-color:#ccc;border:2px solid #333;
}
#right
{overflow:hidden;zoom:1; border:2px solid #333;background:#ccc url(http://www.baidu.com/img/baidu_logo.gif) no-repeat;
}
</style>
</head>
<body>
<div id="left"> left </div>
<div id="right"> 1111<br />1111<br />1111<br />1111<br />1111<br />1111<br />111<br />11</div>
</body>
</html>
这里有几种方法
http://www.cssass.com/blog/index.php/2008/31.html
相关文章推荐
- CSS网页布局入门教程6:左列固定,右列宽度自适应
- DIV+CSS 布局一行两列,左列固定宽度,右列自适应宽度;设置最小宽度,窗口小的时候显示滚动条.
- DIV+CSS 布局一行两列,左列固定宽度,右列自适应宽度;设置最小宽度,窗口小的时候显示滚动条.
- DIV+CSS 布局一行两列,左列固定宽度,右列自适应宽度;设置最小宽度,窗口小的时候显示滚动条.
- CSS网页布局入门教程6:左列固定,右列宽度自适应
- DIV+CSS 布局一行两列,左列固定宽度,右列自适应宽度;设置最小宽度
- 左侧固定宽度-右侧自适应布局
- 二列右列宽度自适应布局
- CSS三栏布局——中间固定两边自适应宽度
- 使用CSS实现三栏自适应布局(两边宽度固定,中间自适应)
- 狂人日记学习 之五 左列固定宽度,右列自适应
- CSS三栏布局(两边固定中间自适应宽度)的方法
- CSS网页布局入门教程5:二列宽度自适应
- CSS网页布局入门教程7:二列固定宽度居中
- html--三栏布局(两边固定宽度,中间自适应)
- 横向两列布局(左列固定,右列自适应)的4中实现方式
- 常用布局-列宽度是固定宽度还是自适应
- CSS三列布局之左右宽度固定,中间元素自适应问题
- 左侧固定宽度,右侧自适应宽度的CSS布局
- 沫沫金:2014最新全浏览器兼容左列固定右列自适应宽度技巧大公开