一个css问题

php_way 2014-09-30 09:23:58
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>html页面</title>
<style>
*{padding: 0;margin: 0}
#main{width:auto;height: auto;background-color: #ccc;position: relative;padding: 20px;}
#left{position: absolute;width: 300px;height: 500px;background-color: blue;}
#right{margin: 0 0 0 330px;background-color: yellow;}
#footer{width: auto;height: 100px;background-color: orange;text-align: center;}
</style>
</head>
<body>
<div id='main'>
<div id="left">左边</div>
<div id="right">右边</div>
</div>
<div id="footer">底部</div>
</body>
</html>

问题是:footer怎么样下沉到最底部
我想要达到的效果是:
-----“右边"高度和宽度自适应,窗口变化时自动跟着变化
...全文
104 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
php_way 2014-09-30
  • 打赏
  • 举报
回复
谢谢楼上的兄弟,已经用另外的方法解决了
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>html页面</title>
<style>
*{padding: 0;margin: 0}
#main{width:auto;height: auto;background-color: #ccc;padding: 20px;overflow: auto;}
#left{float:left;width: 300px;height: 500px;background-color: blue;position: relative;}
#right{background-color: yellow;margin-left: 330px;}
#footer{width: auto;height: 100px;background-color: orange;text-align: center;clear:both;}
</style>
</head>
<body>
<div id='main'>
	<div id="left">左边</div>
	<div id="right">右边</div>
</div>

<div id="footer">底部</div>
</body>
</html>
可以更狠点 2014-09-30
  • 打赏
  • 举报
回复

主要是position:fixed这个属性

61,112

社区成员

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

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