建站软件 优化软件 编程软件 网页辅助 站群程序 网站程序 图像处理 资源教程 字体下载 推荐软件


您的位置:首页 > div+css > DIV+CSS布局实例一

DIV+CSS布局实例一

时间:2015-01-29 10:01:11  来源:免费模板网 作者:风雪 阅读次数 tags布局实例

  今天我们学做的是完成一个网站框架的搭建,这个网站布局的基础
 

有下面这样的一个
DIV+CSS布局,要求如下:

整个页面充满窗口,当窗口缩小放大时自动调整,不能出现窗口的滚动条,但小于定义的最小宽高时可以出现。
头部(1)固定高度40px,宽度自适应窗口宽度。
左侧(2)固定宽度150px,高度为窗口高度减去头部的40px,不是固定值。
右侧(4)与左侧(2)一样。
中间(3)宽高都是不固定的,宽是窗口宽度减去左右两侧,共减去300px,高度是窗口高度减去头部(1)跟底部(5),共减去100px。
底部(5)是中间(3)的附属部分,高度固定60px。
最后加个小小附加题,在中间(3)里加个input文本框,上左右边距始终10px,宽度不固定,随着中间(3)宽度的变化而变化。
不能使用javascript,只能用css,不考虑IE6。

具体的实现代码为:

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style>
        html,body{margin: 0;padding: 0;background: yellow;height: 100%;}
       .top{height: 40px;width: 100%;background: red;}
       .content{height: 100%;background: green;position: relative;}
       .left{width: 150px;position:absolute;top:0;left:0;height: 100%;background: #4169e1;}
       .right{width:150px;position:absolute;right:0px;top:0;background: #9acd32;}
        .main{height: 100%;margin-left: 150px;margin-right: 150px;background: #8a2be2;position:relative}
        .b{position:absolute;bottom:0px;left:0;height: 60px;width: 100%;background: yellow;}
        .a{}

    </style>
</head><body>
<div class="top"></div>
<div class="content">
    <div class="left"></div>
    <div class="main">
        <div class="a"></div>
        <div class="b"></div>
    </div>
    <div class="right"></div>

</div>
<script>
    window.onload=function(){
        console.log(document.body.clientHeight)
        console.log(document.body.scrollHeight)
    }
</script>
</body>
</html>

本文地址:https://www.freemoban.com/bjrm/2015/0129/323.html

猜你喜欢
栏目推荐
模板推荐

Copyright:www.freemoban.com 免费模板网 All Rights Reserved 网站备案:辽ICP备19014872号-2   辽公网安备 21010602000376号  辽公网安备:42900402000182号

免责声明:本站部分资源来自互联网收集,版权归原创者所有,如果侵犯了你的权益,我们会及时删除侵权内容,联系QQ:1615187561 谢谢合作!