美文网首页
css写布局

css写布局

作者: Lazy一boy | 来源:发表于2018-08-06 23:42 被阅读0次

一:左右布局

1.用float浮动来实现左右布局:
HTML代码:

<div class="father clearfix">
<div class="son1"></div>
<div class="son2"></div>
</div>

css代码:

.clearfix::{content:''; display:block; clear:both;}
.father{width:205px;  }
.son1{float:left; width:100px; height:100px; background:black;}
.son2{float:left; width:100px; height:100px; background:green;}

演示:


01.png

2用绝对定位来实现左右布局:
HTML代码:

<div class="father ">
<div class="son1"></div>
<div class="son2"></div>
</div>

css代码:

.father{
            position: relative;
            border: 1px solid red;
            width: 205px;
}
.son1{
          position: absolute;
            left:0; 
            border: 1px solid red;
            background: black;
            width: 100px;
            height: 100px;
        }
.son2{
            position: absolute;
            right: 0;
            border: 1px solid red;
            background: green;
            width: 100px;
            height: 100px;

演示:


01.png

二:多列布局:

HTM代码:

    <!--头部  -->
    <div class="header">
        <div class="headerfl"></div>
        <div class="headerfr">
            <div class="top"></div>
            <div class="down"></div>
        </div>
    </div>
    <!-- 主体 -->
    <div class="container">
        <div class="containerfl"></div>
        <div class="containerfr">
            <div class="da">
                <div class="dafl">
                    <div class="dafl1"></div>
                    <div class="dafl2"></div>
                    <div class="dafl3"></div>
                </div>
                <div class="dafr"></div>
            </div>
            <div class="xiao"></div>
        </div>
    </div>
    <div class="footer"></div>

css代码:

.header{
            width: 1180px;
            height: 100%;
            margin: 10px auto;


        }
        .headerfl{
            width: 200px;
            height: 100px;
            background-color: red;
            float: left;
            margin-right: 20px;
        }
        .headerfr{
            width: 960px;
            height: 100px;
            float: left;
        }
        .top{
            width: 100px;
            height: 50px;
            background-color: green;
            float: right;
            margin-bottom:10px 
        }
        .down{
            width: 100%;
            height: 40px;
            background-color: green;
            float: left;
        }
        .container{
            width: 1180px;
            height: 100%;
            margin: 10px auto;
            
        }
        .containerfl{
            width: 250px;
            height: 500px;
            
            float: left;
            background-color: yellow;
        } 
        .marginerfr{
            width: 920px;
            height: 500px;
            margin-left: 20px;
            float: right;
        }
        .da{
           width: 920px;
           height: 450px;
           margin-bottom: 10px;
           float: left;
        }
        .dafl{
            width: 850px;
            height: 450px;
            margin: 0 5px;
            float: left;
        }
        .dafl1{
            width: 850px;
            height: 250px;
            background-color: blue;
            float: left;
        }
        .dafl2{
            width: 850px;
            height: 100px;
            background-color: blue;
            margin: 10px auto;
            float: left;
        }
        .dafl3{
            width: 850px;
            height: 80px;
            background-color: blue;
            float: left;
        }
        .dafr{
            width: 60px;
            min-height: 450px;
            background-color: black;
            float: left;
        }
        .xiao{
            width: 920px;
            height: 40px;
            background-color: green;
            float: left;
        }
       .footer{
        width: 1180px;
        height: 70px;
        background-color: red;
        clear: both;
        margin: 10px auto;
       }

演示:


02.png

相关文章

  • css写布局

    一:左右布局 1.用float浮动来实现左右布局:HTML代码: css代码: 演示: 2用绝对定位来实现左右布局...

  • 文章收藏

    CSS布局 CSS布局方案整理

  • css

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

  • css flex布局详解

    css flex布局详解 css flex布局详解1css flex布局详解2

  • NUI

    css方式写iOS布局 https://github.com/tombenner/nui

  • 经典CSS布局:双飞翼和圣杯布局

    圣杯布局 HTML CSS 双飞翼布局 HTML CSS Flex布局 HTML和圣杯布局一样CSS

  • css重温(鉴css世界,掘金CSDN)

    流布局概念 1.流又称文档流,是css基本定位和布局方式。流体布局是html的默认布局方式,如果你写html不写c...

  • 常见 CSS 布局方式

    前言 温馨提示:本文较长,图片较多,本来是想写一篇 CSS 布局方式的,但是奈何 CSS 布局方式种类太多并且实现...

  • 圣杯布局2019-12-18

    圣杯布局 css html 双飞翼布局 css html

  • ##深入学习CSS布局系列(一)布局常用属性

    @(CSS)[CSS, 布局] 深入学习CSS布局系列(一)布局常用属性 一直感觉自己对CSS的各个属性很了解,可...

网友评论

      本文标题:css写布局

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