Home > Article > Web Front-end > 一个css问题_html/css_WEB-ITnose
<!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>
主要是position:fixed这个属性
谢谢楼上的兄弟,已经用另外的方法解决了
<!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>