web前端的float布局与flex布局

flex布局

复制代码
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>flex</title>
        <style>
            .container{
               width: 100%;
               height: 100px;
                background-color: aqua;
                display: flex;
                flex-direction: row;
                justify-content: space-around;
            }
            .item{
                width: 100px;
                height: 100px;
                border: black solid 2px;
                text-align: center;
            }
        </style>                                             
    </head>
    <body>
        <div class="container">
            <div class="item" style="background-color: palegoldenrod;">首页</div>
            <div class="item" style="background-color: palegreen;">课程体系</div>
            <div class="item" style="background-color: pink;">开班信息</div>
            <div class="item" style="background-color: papayawhip;">新闻资讯</div>
        </div>
    </body>
</html>

float布局

复制代码
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>float</title>
        <style>
            .float{
               float: left;
               width: 100px;
               height: 200px;
               background-color: aqua;
            }
            .item{
                background-color: bisque;
                width: 100%;
                height: 500px;
            }
        </style>                                             
    </head>
    <body>
        <div class="container">
            <div class="float">首页</div>
            <div class="float">课程体系</div>
            <div class="float">开班信息</div>
            <div class="float">新闻资讯</div>
            <div class="item"></div>
        </div>
    </body>
</html>
相关推荐
我叫张小白。9 分钟前
Vue3 Hooks:逻辑复用的解决方案
前端·javascript·vue.js·前端框架·vue
S***t71412 分钟前
前端物联网开发
前端·物联网
我叫张小白。20 分钟前
Vue3 Props 的使用:组件间数据传递的桥梁
前端·javascript·vue.js·vue3
r***869820 分钟前
Nginx解决前端跨域问题
运维·前端·nginx
广州华水科技27 分钟前
单北斗GNSS在桥梁变形监测中的关键应用与技术优势分析
前端
IT_陈寒28 分钟前
Python 3.12新特性实战:10个让你效率翻倍的代码优化技巧
前端·人工智能·后端
z***948429 分钟前
Redis 6.2.7安装配置
前端·数据库·redis
2301_8072886331 分钟前
MPRPC项目制作(第四天)
java·服务器·前端
J***793931 分钟前
前端在移动端中的React Native Windows
前端·react native·react.js
阿雄不会写代码32 分钟前
PPTX报错AttributeError: module ‘collections‘ has no attribute ‘Container‘
前端