美文网首页
前端开发-常见CSS布局

前端开发-常见CSS布局

作者: 阿尔法乀 | 来源:发表于2017-11-20 15:26 被阅读0次
css布局.jpg

常见的两列布局

float浮动布局

<div class="float-container">  
    <div class="float-left">左边</div>  
    <div class="float-right">左边div宽固定</div>  
</div>
.float-container{ width:100%;height:100px;}  
.float-container .float-left{float:left;width:100px;height:100%;background: #1ABC9C;}  
.float-container .float-right{height:100%;margin-left:100px;background: #FD482C;}  

flex布局

<div class="flex-container">  
    <div class="flex-left">左边</div>  
    <div class="flex-right">左边div宽固定</div>  
</div> 
.flex-container{ width:100%;height:100px;display:flex;display: -webkit-flex; }  
.flex-container .flex-left{width:100px;height:100px;flex:none;background: #1ABC9C;}  
.flex-container .flex-right{height:100px;background: #FD482C;flex:1;white-space:nowrap; }  

常见的三列布局

float浮动布局

<div class="float-contain">  
    <div class="left">左栏</div>
    <div class="right">右栏</div>
    <div class="middle">中间栏</div>
</div>
.float-contain{ width:100%;height:100px;}  
.float-contain .left{float:left;width:100px;height:100%;background: #1ABC9C}  
.float-contain .right{float:right;width:100px;height:100%;background: #FD482C}
.float-contain .middle{height:100%;background: yellow; margin-left: 100px;margin-right: 100px;}

position定位

<div class="pos-contain">  
    <div class="left">左栏</div>
    <div class="middle">中间栏</div>
    <div class="right">右栏</div>
</div>
.pos-contain{ width:100%;height:100px;position:relative;}  
.pos-contain .left{position: absolute;top:0;left:0;width:100px;height:100%;background: #1ABC9C}  
.pos-contain .right{position: absolute;top:0;right:0;width:100px;height:100%;background: #FD482C}
.pos-contain .middle{height:100%;background: yellow; margin-left: 100px;margin-right: 100px;}

flex布局

<div class="flex-contain">  
    <div class="left">左栏</div>
    <div class="middle">中间栏</div>
    <div class="right">右栏</div>
</div>
.flex-contain{ width:100%;height:100px;display:flex;display: -webkit-flex;}  
.flex-contain .left{width:100px;background: #1ABC9C;flex:none;} 
.flex-contain .right{width:100px;background: #FD482C;flex:none;} 
.flex-contain .middle{width: 100%;background:yellow;flex:1;}

圣杯布局

<div id="container">
    <div class="center">center</div>
    <div class="left">left</div>
    <div class="right">right</div>
</div>
#container{padding:0 210px;overflow: hidden;font-size: 30px;}
.left,.center,.right{float: left;}
.center{ width:100%;height: 50px;background: blue;}
.left{position:relative;left: -210px; width:200px;height: 100px;margin-left: -100%;background: red;}
.right{ position: relative;right: -210px;width: 200px;height: 100px;margin-left: -200px;background: green;}

双飞翼布局

<div id="container2">
     <div class="center2">
         <div class="wrap">center2</div>
     </div>
     <div class="left2">left2</div>
     <div class="right2">right2</div>
</div>
#container2{width:100%; }
.left2,.right2, .center2{ float: left;}
.center2{width:100%; }
.center2 .wrap{height: 200px;margin-left: 210px;margin-right: 210px;background: #392;}
.left2{ width:200px;height: 100px;background: red;margin-left: -100%;}
.right2{width:200px; height: 100px;background: blue;margin-left: -200px; }

相关文章

  • 前端开发-常见CSS布局

    常见的两列布局 float浮动布局 flex布局 常见的三列布局 float浮动布局 position定位 fle...

  • CSS基本布局整理

    前言 css布局是前端开发必须掌握的基本内容,前端学习之css基本布局整理。 基本布局 左右布局 div结构: f...

  • web开发的一些资源干货

    前端库——前端开发,CSS3动画特效等。 CSS入门教程——本指南适合 CSS 的初学者 学习CSS布局——如果你...

  • css

    css基础css选择器css常见样式1css常见样式2CSS布局上CSS布局下flex布局塔防小游戏flex布局青...

  • CSS布局

    CSS入门(3) CSS的常见布局 CSS常见布局使用display属性(文档流)+position属性(定位)+...

  • 前端Flex布局

    在 CSS2的时代,前端的布局基本上采用标准流配合浮动来进行开发,从CSS3开始提供了Flex布局(弹性布局)来适...

  • 20206月计划

    1,熟悉css常见布局,flex布局,移动端布局 2,掌握nuxt,配置,开发等等 3,vue剩下的文档看完 4,...

  • 实现三栏布局5种方式

    前言 前端开发中,布局是前端基础的内容,而其中三栏布局在实际开发和面试中最常见,三栏布局是指中间自适应两边固定宽,...

  • 前端页面中几种常用的flex布局

    以下是前端开发中,常见的几种页面布局,使用flex实现 1.布局一 2.布局2 3.布局3

  • CSS布局

    CSS的常见布局 CSS常见布局使用display属性(文档流)+position属性(定位)+float属性(浮...

网友评论

      本文标题:前端开发-常见CSS布局

      本文链接:https://www.haomeiwen.com/subject/uezevxtx.html