1.一列布局

html:

<div class="header"></div>
<div class="body"></div>
<div class="footer"></div>

css:

      .header{
height: 100px;
background: pink;
}
.body{
height:500px;
background: blue;
}
.footer{
height:100px;
background: #ddd;
}

2.两列布局(指定宽度)

html:

    <div class="left"></div>
<div class="right"></div>

css:

       .left{
width:20%;
height: 500px;
float: left;
background:#333;
}
.right{
width:80%;
height:500px;
float: left;
background: pink
}

3.双飞翼布局(中间自适应,左右列固定宽度)

html:

    <div class="main">
<div class="cont"></div>
</div>
<div class="left"></div>
<div class="right"></div>

css:

       .main {
float: left;
width: 100%;
height: 500px;
}
.cont {
height: 500px;
background-color: aqua;
margin-left: 300px;
margin-right: 300px;
}
.left {
float: left;
width: 300px;
height: 500px;
margin-left: -100%;
background-color: pink;
}
.right {
float: left;
width: 300px;
height: 500px;
margin-left: -300px;
background-color: yellow;
}

 4.多栏布局

栅格系统,是bootstrap常用的布局模式,下列就举个简单四栏例子

html:

    <div class="col"></div>
<div class="col"></div>
<div class="col"></div>
<div class="col"></div>

css:

    .col{
width:25%;
height:500px;
float: left;
background: #ccc;
}
.col:nth-child(1){
background: red;
}
.col:nth-child(2){
background: green;
}
.col:nth-child(3){
background: black;
}
.col:nth-child(4){
background: yellow;
}

常见还有column-count、column-gap、column-rule、columns

5.弹性布局(flex)
html:
   <ul>
<li><a href="#">菜单1</a></li>
<li><a href="#">菜单2</a></li>
<li><a href="#">菜单3</a></li>
<li><a href="#">菜单4</a></li>
</ul>

  css:

    ul{
display: flex;
height:100px;
width:100%;
}
ul li{
flex: auto;
list-style:none;
text-align:center;
border:1px solid red;
}

  6.瀑布式布局

css常用布局的更多相关文章

  1. CSS常用布局实现方法

    CSS 布局对我来说,既熟悉又陌生.我既能实现它,又没有很好的了解它.所以想总结一下,梳理一下 CSS 中常用的一列,两列,三列布局等的实现方法.本文小白,仅供参考.但也要了解下浮动,定位等. 一.一 ...

  2. css 常用布局

    「前端那些事儿」③ CSS 布局方案 我们在日常开发中经常遇到布局问题,下面罗列几种常用的css布局方案 话不多说,上代码! 居中布局 以下居中布局均以不定宽为前提,定宽情况包含其中 1.水平居中 a ...

  3. CSS常用布局整理(二)

    1-2-1单列变宽布局 side列定宽300px,content列变宽,尺寸是100%-300px.核心的问题就是浮动列的宽度应该等于“100% - 300px”,而CSS显然不支持这种带有减法运算的 ...

  4. CSS常用布局整理

    固定宽度布局 1-2-1布局(浮动) <html xmlns="http://www.w3.org/1999/xhtml"> <head> <titl ...

  5. CSS常用布局方式-两列布局、三列布局

    CSS基础 2.几种布局方式1)table布局 当年主流的布局方式,第一种是通过table tr td布局 示例: <style type="text/css"> ta ...

  6. html+css 常用布局

    1.中间固定宽度,两侧自适应 1.1 flex布局 <!DOCTYPE html><html lang="en"> <head> <met ...

  7. CSS常用布局技巧 实例

    末尾用省略号! white-space: nowrap; overflow: hidden; text-overflow: ellipsis; ######################## 两个i ...

  8. CSS常用布局学习笔记

    水平居中-行内元素 如果是文字和图片这类的行内元素,则在其父级元素上加上样式:text-align:center; 水平居中-定宽块元素 div{ width:100px; margin:0 auto ...

  9. DIV+CSS常用网页布局技巧!

    以下是我整理的DIV+CSS常用网页布局技巧,仅供学习与参考! 第一种布局:左边固定宽度,右边自适应宽度 HTML Markup <div id="left">Left ...

随机推荐

  1. Meterpreter命令详解

      0x01初识Meterpreter 1.1.什么是Meterpreter Meterpreter是Metasploit框架中的一个扩展模块,作为溢出成功以后的攻击载荷使用,攻击载荷在溢出攻击成功以 ...

  2. Atcoder Tenka1 Programmer Contest 2019

    C 签到题,f[i][0/1]表示以i结尾最后一个为白/黑的最小值,转移显然. #include<bits/stdc++.h> using namespace std; ; ]; char ...

  3. C语言程序设计I—寒假作业安排

    20188402http://www.cnblogs.com/1793979463hyx/

  4. halcon预处理函数

    颜色空间变换 trans_from_rgb(ImageRed, ImageGreen, ImageBlue :ImageResult1, ImageResult2, ImageResult3 : Co ...

  5. codeforces-1140 (div2)

    A.维护一个前缀最大值,不断跳即可 #include <map> #include <set> #include <ctime> #include <cmat ...

  6. Battery Historian 使用常用命令

    一.重置电池数据收集数据 打开电池数据获取:adb shell dumpsys batterystats --enable full-wake-history 重置电池数据: adb shell du ...

  7. crm 数据展示 和分页思想(一)

    1. 数据的展示 数据通过ORM查询出来 对象列表 QuerySet 1. 普通的字段 对象.字段名 ——> 数据库中的值 <td>{{ customer.phone }}</ ...

  8. Mysql漏洞修复方法思路及注意事项

    [系统环境] 系统环境:Red Hat Enterprise Linux Server release 5.4 (Tikanga)  +  5.7.16 MySQL Community Server  ...

  9. [物理学与PDEs]第3章习题1 只有一个非零分量的磁场

    设磁场 ${\bf H}$ 只有一个非零分量, 试证明 $$\bex ({\bf H}\cdot\n){\bf H}={\bf 0}. \eex$$ 证明: 不妨设 ${\bf H}=(0,0,H_3 ...

  10. Mocha

    Mocha https://mochajs.org/#installation Mocha is a feature-rich JavaScript test framework running on ...