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. java 发送 mail 纯文本发送和html格式发送

    一:需要引入mail maven jar包 <!--邮件发送包--> <dependency> <groupId>javax.mail</groupId> ...

  2. python之路day01--变量

    一.变量 变量就是将一些运算的中间结果暂存到内存中,以便后续代码块调用. 规范: 1.必须由数字.字母.下划线任意组合,且不能数字开头. 2.不能是python中的关键字.如:‘print’ 'and ...

  3. (二分查找 拓展) leetcode278. First Bad Version

    You are a product manager and currently leading a team to develop a new product. Unfortunately, the ...

  4. uImage

    linux内核经过编译后会生成一个ELF格式的可执行程序,叫vmlinux或vmlinuz,是原始的未经任何处理加工的原版内核ELF文件:嵌入式系统烧录的一般不是这个vmlinuz/vmlinux,而 ...

  5. Fiddler--QuickExec

    QuickExec在Fiddler中提供了比较快捷的功能服务. 在QuickExec输入框中输入命令,能快速地得到想要的结果. 快捷键:打开Fiddler后,按“Alt+q”,可将光标定位到Quick ...

  6. Shell脚本之grep

    1. 过滤空行   grep -v ^$

  7. JWT入门简介

    官网:https://jwt.io/ 文档:https://jwt.io/introduction/ 目录 什么是JWT 头部(Header) 载荷(Payload) 签名(Signature) JW ...

  8. 使用Maven插件构建Spring Boot应用程序镜像

    使用Maven插件构建Spring Boot应用程序的Docker镜像. 环境准备 1.Linux系统 2.安装JDK,Maven 3.安装Docker 应用实践 1.在应用程序根目录下添加Docke ...

  9. 用 Mathematica 获取图片的 RGB 三基色

    ColorConvert[*, "RGB"] // InputForm 其中 * 表示你把你的图片拖入 Mathematica 中.

  10. [再寄小读者之数学篇](2014-06-20 求极限---Jordan 不等式的应用)

    证明: 当 $\lm<1$ 时, $\dps{\lim_{R\to+\infty} R^\lm\int_0^{\pi/2} e^{-R\sin\tt}\rd \tt=0}$. 证明: 由 $$\ ...