web前端开发之布局:先看效果图,最简单的左右布局。有可能还会被面试问道哈哈哈。
一看也没什么特别之处,就是左边固定,右边自适应,就这么简单。
原理:通过设置一个margin-left;或者margin-right就可以搞定。方法有很多,这次就只介绍这种设置margin的。
代码:
这是css部分:
body{
margin:0;
padding:0;
}
#wrap{
overflow:hidden;*zoom:1;
}
#content,#sidebar{
background-color:#eee;
}
#sidebar{
float:left;width:px;
background-color:pink;
position:fixed;
top:50px;
left:0;
}
#content{
margin-left:px;
height:px;
background-color:#eaa;
margin-top:50px;
}
#footer{
background-color:#f00;
color:#fff;
margin-top:1em;
}
html部分:
divstyle="width:%;height:50px;line-height:50px;background-color:#ccc;position:fixed;top:0;left:0;"这是头部:web前端开发大全/div
divid="wrap"
divid="sidebar"style="height:px;"固定宽度区:/div
divid="content"style="height:px;"自适应区/div
/div
divid="footer"这是尾部,想写什么就写什么,这是一个神奇的地方/div
非常简单,如果你还有更好的方法,欢迎前来投稿交流。只为学习更多,技术更上一层楼,早日升职加薪,赢取白富美,走上人生巅峰。