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. django restframework permission

    与 authentication 和 throttling 一起,permission 决定是应该接受还是拒绝访问请求.权限检查总是在视图的最开始处运行,在任何其他代码被允许进行之前.权限检查通常会使 ...

  2. python中 yield的用法和生成器generator的说明

    详情: https://www.cnblogs.com/python-life/articles/4549996.html

  3. GIT-Bonobo.Git.Server的使用

    GIT-Bonobo.Git.Server的使用 登录 (默认用户:admin/admin) 创建用户: 创建团队,勾选用户 创建新库 保存完成!

  4. 第十四节:Lambda、linq、SQL的相爱相杀(3)

    一. SQL 开篇 1. where用法 #region 封装EF调用SQL语句查询 public static List<T> ExecuteQuery<T>(string ...

  5. django - 总结 - ORM性能

    QuerySet 1.惰性查询 2.缓存机制 3.可迭代 4.可切片 -------------------------------------------------------在一个新创建的查询集 ...

  6. [物理学与PDEs]第1章第3节 真空中的 Maxwell 方程组, Lorentz 力 3.2 Lorentz 力

    1. Lorentz 假定, 不论带电体的运动状态如何, 其所受的力密度 (单位体积所受的力) 为 $$\bex {\bf F}=\rho {\bf E}+{\bf j}\times{\bf B} = ...

  7. Chrome 禁止从页面打开 Data URI 网址了

    现如今,网民的网络账户被盗,很有可能是被“钓鱼”了.去年的一份安全报告中指出:“近85%的资金损失是通过钓鱼网址泄露支付信息造成的”. 传统的钓鱼网站通常是申请一个和被冒充网站相似的域名,比如 tao ...

  8. Coursera, Big Data 3, Integration and Processing (week 1/2/3)

    This is the 3rd course in big data specification courses. Data model reivew 1, data model 的特点: Struc ...

  9. apache中 sed 指定文件中某字符串增加行

    #!/bin/bash #在 servername 域名 字符串后面添加指定字符串 servername=`grep ServerName httpd-vhosts.conf |awk '{print ...

  10. C#利用VUDP.cs开发网络通讯应用例程

    VClassLib-CS项目Github地址:https://github.com/velscode/VClassLib-CS VUDP文档地址:https://github.com/velscode ...