Maison  >  Questions et réponses  >  le corps du texte

css - Comment implémenter cette mise en page avec Flex?

Comment utiliser flex pour réaliser cette mise en page ? Je n'ai pas pu finir d'écrire avant la troisième fois. S'il vous plaît, aidez-moi.

<p class="pic">
    <p class="pic1"></p>
    <p class="pic2"></p>
    <p class="pic3"></p>
    <p class="pic4"></p>
</p>

<style>
    .pic{
        display: flex;
        width: 400px;
        height: 400px;
        margin: 100px auto;
        flex-wrap: wrap;
    }
    .pic1{
        flex: 1;
        height: 100%;
        background-color: pink;
    }
    .pic2{
        flex: 1;
        height: 50%;
        background: #C81623;
    }
    .pic3{
        /*width: 25%;*/
        /*float: left;*/
        /*height: 50%;*/
        /*background-color: green;*/
    }
    ...
ringa_leeringa_lee2668 Il y a quelques jours933

répondre à tous(2)je répondrai

  • 怪我咯

    怪我咯2017-06-30 09:58:55

    Probablement comme ci-dessous

    <!DOCTYPE html>
    <html>
    
    <head>
        <meta charset="utf-8">
        <title></title>
        <style media="screen">
            #main {
                display: flex;
                height: 500px;
            }
    
            #left {
                width: 200px;
                background: red;
            }
    
            #right-box {
                display: flex;
                flex-direction: column;
                background: blue;
                flex: 1;
            }
    
            #right-top {
                height: 200px;
                background: yellow;
            }
    
            #right-bottom-box {
                display: flex;
                flex: 1;
            }
    
            #bottom-left {
                width: 50%;
                background: pink;
            }
            
            #bottom-right {
                width: 50%;
                background: magenta;
            }
        </style>
    </head>
    
    <body>
        <p id="main">
            <p id="left"></p>
            <p id="right-box">
                <p id="right-top"></p>
                <p id="right-bottom-box">
                    <p id="bottom-left"></p>
                    <p id="bottom-right"></p>
                </p>
            </p>
        </p>
    </body>
    
    </html>

    Effet

    répondre
    0
  • ringa_lee

    ringa_lee2017-06-30 09:58:55

    .flex-box {
      display: flex;
    }
    .flex-1 {
      flex: 1;
    }
    .flex-2 {
      flex: 2;
    }
    .flex-3 {
      flex: 3;
    }
    <p class="flex-box">
      <p class="flex-2">pic</p>
      <p class="flex-3">
        <p>pic</p>
        <p class="flex-box">
          <p class="flex-1">pic</p>
          <p class="flex-1">pic</p>
        </p>
      </p>
    </p>

    répondre
    0
  • Annulerrépondre