• 技术文章 >web前端 >html教程

    实现一个三列布局(左右侧固定,中间自适应宽度)_html/css_WEB-ITnose

    2016-06-24 11:20:56原创954

    html代码(第一二种方法):

    左侧固定区
    右侧固定区
    中间自适应区

    css代码:

    第一种方法(定位):

    .left {  position: absolute;  top: 0;  left: 0;  width: 100px;  height: 200px;  background-color: red; } .mid {  margin-left: 100px;  margin-right: 200px;  height: 200px;  background-color: blue; } .right {  position: absolute;  top: 0;  right: 0;  width: 200px;  height: 200px;  background-color: yellow; }

    第二种方法(浮动):

    .left { float: left; width: 100px; height: 200px; background-color: red;}.mid { height: 200px; background-color: blue;}.right { float: right; width: 200px; height: 200px; background-color: yellow;}

    第三种方法(负边距):

    html代码:

    中间自适应区中间自适应区中间自适应区中间自适应区中间自适应区中间自适应区中间自适应区中间自适应区中间自适应区中间自适应区中间自适应区中间自适应区
    左边固定区
    右边固定区

    css代码:

    .fl { float: left; }.center {  width: 100%;  height: 200px;  background: yellow;}  .center .mid{    margin-right: 100px;    padding: 0 110px;  }.left{    margin-left: -100%;    width: 100px;    height: 200px;    background: green;}.right{    margin-left: -200px;    width: 200px;    height: 200px;    background: blue;}

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    上一篇:用Css给你的图片加上Instagram滤镜_html/css_WEB-ITnose 下一篇:自己动手写 PHP MVC 框架(40节精讲/巨细/新人进阶必看)

    相关文章推荐

    • Hexo建博小结• 第 9 章 音频和视频_html/css_WEB-ITnose• 使用meta实现页面的定时刷新或跳转_html/css_WEB-ITnose• 糟糕的css用法 1_html/css_WEB-ITnose• button与submit_html/css_WEB-ITnose
    1/1

    PHP中文网