浮动练习(1)

复制代码
要求呈现图案:

法一:不建议
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title> </title>
        <style>
            div:nth-child(1){
                width: 100px;
                height: 100px;
                background-color: aqua ;
                float: left;
            }
            div:nth-child(2){
                width: 300px;
                height: 100px;
                background-color: purple ;
            
            }
            div:nth-child(3){
                width: 100px;
                height: 200px;
                background-color: gold ;
                float: left;
            }
            div:nth-child(4){
                width: 100px;
                height: 200px;
                background-color: red ;
                float: left;
            }
            div:nth-child(5){
                width: 300px;
                height: 100px;
                background-color: black ;
                
            }
            div:nth-child(6){
                width: 300px;
                height:100px;
                background-color: palegoldenrod ;
            
            }
        </style>
    </head>
    <body>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        
    </body>
</html>

法二:建议用此方法
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        .container{
            width: 300px;
            height: 300px;
            background-color: gray;
            
        }
        .container .top{
            width: 300px;
            height: 100px;
            background-color: blue;
            
        }
        .container .bottom{
            width: 300px;
            height: 200px;
            background-color: purple;
            
            }
        .container .top .left{
            width: 100px;
            height: 100px;
            background-color: red;
            
        }
        .container .bottom .left{
            width: 100px;
            height: 200px;
            background-color: yellow;
            float: left;
        }
        .container .bottom .center{
            width: 100px;
            height: 200px;
            background-color: pink;
            float: left;
        }
        .container .bottom .right{
            width: 100px;
            height: 200px;
            background-color: green;
            float: left;
        }
        .container .bottom .right .top{
            width: 100px;
            height: 100px;
            background-color: gold;    
        }
        .container .bottom .right .bottom{
            width: 100px;
            height: 100px;
            background-color: greenyellow;

        }
            
        </style>
</head>
<body>
        <div class="container">
            <div class="top">
                <div class="left"></div>
            </div>
            <div class="bottom">
               <div class="left"></div>
               <div class="center"></div>
               <div class="right">
                 <div class="top"></div>
                   <div class="bottom"></div>
               </div>
            </div>            
        </div>
</body>
</html>
相关推荐
CrissChan18 分钟前
Pycharm 函数注释
java·前端·pycharm
小小小小宇1 小时前
Vue.nextTick()笔记
前端
小约翰仓鼠2 小时前
vue3子组件获取并修改父组件的值
前端·javascript·vue.js
Lin Hsüeh-ch'in2 小时前
Vue 学习路线图(从零到实战)
前端·vue.js·学习
烛阴3 小时前
bignumber.js深度解析:驾驭任意精度计算的终极武器
前端·javascript·后端
计蒙不吃鱼3 小时前
一篇文章实现Android图片拼接并保存至相册
android·java·前端
全职计算机毕业设计3 小时前
基于Java Web的校园失物招领平台设计与实现
java·开发语言·前端
啊~哈3 小时前
vue3+elementplus表格表头加图标及文字提示
前端·javascript·vue.js
小小小小宇4 小时前
前端小tips
前端