flex布局案例

其实这是第七天,昨天写完忘记发了,今天补上。

做的案例是下面这样的


demo.png

demo1.png

第一个的代码是这样的

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

    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            max-width: 540px;
            min-width: 320px;
            margin: 0 auto;
        }

        a {
            text-decoration: none;
            color: black;
        }

        .container {
            width: 90%;
            margin: 0 auto;
        }

        .header {
            position: relative;
            height: 40px;
            width: 100%;
            margin: 0 auto;
        }

        .header a {
            position: absolute;
            line-height: 40px;
        }

        .header span {
            position: absolute;
            width: 80px;
            left: 50%;
            line-height: 40px;
            transform: translate(-50%);
        }

        .nav {
            height: 50px;
            width: 100%;
            display: flex;
            border-top: 1px solid #ccc;
            border-bottom: 1px solid #ccc;
            justify-content: space-between;

        }

        .nav a {
            font-size: 14px;
            line-height: 50px;
        }

        .job:after {
            content: "▷";
            margin-left: 5px;
            color: #d84511;
        }

        .nav a span {
            margin-left: 10px;

        }

        .nav .box:after {
            content: "▽";
            margin-left: 5px;
            color: #d84511;
        }

        .main {
            display: flex;
            width: 100%;
            height: 80px;
            justify-content: space-between;
            border-bottom: 1px solid #ccc;
        }

        .main .left em {
            display: block;
            font-size: 15px;
            font-weight: 900;
            font-style: normal;
            margin-top: 10px;
        }

        .main .left i {
            display: block;
            font-style: normal;
            font-size: 10px;
            color: darkgrey;
            margin-top: 7px;
        }

        .main .left span {
            display: flex;
            font-size: 12px;
            margin-top: 5px;
            justify-content: space-between;
        }

        .main .left span a {
            background-color: #ccc;
            color: darkgray;
            flex: 0 0 40%;
            text-align: center;
        }

        .right p,
        i {
            display: block;
        }

        .right p {
            font-size: 12px;
            color: #d84511;
        }

        .right i {
            font-style: normal;
            font-size: 12px;
            text-align: right;
            color: darkgrey
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="header">
            <a href="#">◁</a>
            <span>优先兼职</span>
        </div>
        <div class="nav">
            <a href="" class="job">求职意向</a>
            <a href="">
                <span>推荐</span>
                <span>最新</span>
                <span class="box">筛选</span>
            </a>
        </div>
        <div class="main">
            <div class="left">
                <em>前端工程师</em>
                <i>完美数联&nbsp;1000人以上</i>
                <span>
                    <a href="">郑州</a>
                    <a href="">本科</a>
                </span>
            </div>
            <div class="right">
                <p>7k-10k/月</p>
                <i>10:42</i>
            </div>

        </div>
        <div class="main">
            <div class="left">
                <em>前端工程师</em>
                <i>完美数联&nbsp;1000人以上</i>
                <span>
                    <a href="">郑州</a>
                    <a href="">本科</a>
                </span>
            </div>
            <div class="right">
                <p>7k-10k/月</p>
                <i>一天前</i>
            </div>
        </div>
        <div class="main">
            <div class="left">
                <em>前端工程师</em>
                <i>完美数联&nbsp;1000人以上</i>
                <span>
                    <a href="">郑州</a>
                    <a href="">本科</a>
                </span>
            </div>
            <div class="right">
                <p>7k-10k/月</p>
                <i>11月23日</i>
            </div>
        </div>
    </div>
</body>

</html>

第二个案例的代码

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" maximum-scale=1.0 minimum-scale=1.0>
    <title>Document</title>
    <style>
        body {
            max-width: 540px;
            min-width: 320px;
            margin: 0 auto;
        }

        a {
            text-decoration: none;
            color: black;
        }

        .container {
            width: 90%;
            margin: 0 auto;
        }

        .header {
            position: relative;
            height: 30px;
            width: 100%;
            margin: 0 auto;
        }

        .header a {
            position: absolute;
            top: 6px;
        }

        .header span {
            position: absolute;
            width: 40px;
            top: 6px;
            left: 50%;
            transform: translate(-50%);
        }

        .nav {
            height: 60px;
            width: 100%;
            margin-top: 20px;
        }

        .nav span {
            font-size: 14px;
        }

        .nav .box {
            display: flex;
        }

        .nav .box a {
            width: 100px;
            text-align: center;
            margin-right: 10px;
            background-color: #ccc;
            margin-top: 10px;
        }

        .nav1 {
            height: 100px;
            width: 100%;
            margin-top: 15px;
        }

        .nav1 span {
            font-size: 14px;
        }

        .nav1 .box1 {
            display: flex;
            flex-wrap: wrap;
            margin-top: 10px;
        }

        .nav1 .box1 a {
            width: 100px;
            text-align: center;
            background-color: #ccc;
            margin-right: 10px;
            margin-bottom: 10px;
        }

        .nav2 {
            margin-top: 5px;
        }

        .nav2 span {
            font-size: 14px;
        }

        .nav2 .box2 {
            display: flex;
            margin-top: 6px;
        }

        .nav2 .box2 a {
            width: 100px;
            text-align: center;
            background-color: #ccc;
            margin-right: 10px;
        }

        .footer {
            height: 60px;
            margin-top: 100px;
            border-top: 1px solid #999;
            display: flex;
        }

        .footer a:nth-child(1) {
            flex: 1;
            background-color: #ccc;
            height: 40px;
            line-height: 40px;
            text-align: center;
            margin-top: 20px;
            margin-right: 10px;
        }

        .footer a:nth-child(2) {
            flex: 2;
            background-color: #ccc;
            height: 40px;
            line-height: 40px;
            text-align: center;
            margin-top: 20px;
            margin-left: 10px;
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="header">
            <a href="#">◁</a>
            <span>筛选</span>
        </div>
        <div class="nav">
            <span>距离</span>
            <div class="box">
                <a href="">不限</a>
                <a href="">离我最近</a>
            </div>
        </div>
        <div class="nav1">
            <span>结算方式</span>
            <div class="box1">
                <a href="">不限</a>
                <a href="">日结</a>
                <a href="">次日结</a>
                <a href="">周结</a>
                <a href="">半月结</a>
                <a href="">月结</a>
                <a href="">完工结</a>
            </div>
        </div>
        <div class="nav2">
            <span>性别要求</span>
            <div class="box2">
                <a href="">不限</a>
                <a href="">男生可做</a>
                <a href="">女生可做</a>
            </div>
        </div>
        <div class="footer">
            <a>重置</a>
            <a>完成</a>
        </div>

    </div>

</body>

</html>

感觉自己写的不太好,又不知道哪里还可以优化

ε≡٩(๑>₃<)۶ 一心向学

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。