Blogger Information
Blog 40
fans 0
comment 0
visits 37559
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
flex学习总结(1)简介和对比——2019年9月10号20:00分
虎子爸爸
Original
977 people have browsed it

一、flex弹性盒子的特点

  1. 正常盒子——效果图:

flex-1.png

实例

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>flex容器</title>
</head>

<body>
    <style>
        .container {
            /* display: flex; */
            border: 1px solid cadetblue;
            width: 400px;
        }
        
        .container div,
        .container span {
            /* display: inline; */
            width: 50px;
            height: 30px;
            border: 1px solid chocolate;
            margin-left: 10px;
            margin-top: 10px;
            margin-bottom: 10px;
            padding: 10px;
        }
    </style>
    <h4>flex基本概念</h4>
    <dd>——弹性布局flexible box,用来为盒状模型提供最大的布局灵活性</dd>
    <div class="container">
        <div>版块A</div>
        <div>版块B</div>
        <div>版块C</div>
        <span>
            版块D
        </span>
    </div>
</body>

</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

    2.正常盒子行内块元素效果图

flex-4.png

实例

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>flex容器</title>
</head>

<body>
    <style>
        .container {
            /* display: flex; */
            border: 1px solid cadetblue;
            width: 400px;
        }
        
        .container div,
        .container span {
            display: inline-block;
            /*这里是行间块元素*/
            width: 50px;
            height: 30px;
            border: 1px solid chocolate;
            margin-left: 10px;
            margin-top: 10px;
            margin-bottom: 10px;
            padding: 10px;
        }
    </style>
    <h4>flex基本概念</h4>
    <dd>——弹性布局flexible box,用来为盒状模型提供最大的布局灵活性</dd>
    <div class="container">
        <div>版块A</div>
        <div>版块B</div>
        <div>版块C</div>
        <span>
            版块D
        </span>
    </div>
</body>

</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例



    3、flex弹性盒子效果图——和第2种行间块元素有了间距上的变化

flex-5.png

实例

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>flex容器</title>
</head>

<body>
    <style>
        .container {
            display: flex;
            border: 1px solid cadetblue;
            width: 400px;
        }
        
        .container div,
        .container span {
            /* display: inline-block; */
            /*这里是行间块元素*/
            width: 50px;
            height: 30px;
            border: 1px solid chocolate;
            margin-left: 10px;
            margin-top: 10px;
            margin-bottom: 10px;
            padding: 10px;
        }
    </style>
    <h4>flex基本概念</h4>
    <dd>——弹性布局flexible box,用来为盒状模型提供最大的布局灵活性</dd>
    <div class="container">
        <div>版块A</div>
        <div>版块B</div>
        <div>版块C</div>
        <span>
            版块D
        </span>
    </div>
</body>

</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post