如何在每个角落对齐4个段落,在中心对齐1个段落

问题描述 投票:-2回答:1

我想在角落的4段和div的中心1我该怎么办?

html html5 css3
1个回答
1
投票

我希望我理解你的权利。我提供了一个有关的例子:

<!DOCTYPE html>
<html>

  <head>
    <style>
      .container {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-rows: 1fr 1fr 1fr;
        grid-template-areas:
        'first  .     second'
        '.      third .     '
        'fourth .     fifth';
        width: 500px;
        height: 500px;
        border: 1px solid red;
      }
      
      .container > p {
        display: flex;
        justify-content: center;
        align-items: center;
        border: 1px solid black;
      }
      
      .first {
        grid-area: first;
      }
      
      .second {
        grid-area: second;
      }
      
      .third {
        grid-area: third;
      }
      
      .fourth {
        grid-area: fourth;
      }
      
      .fifth {
        grid-area: fifth;
      }
    </style>
  </head>

  <body>
    <div class="container">
      <p class="first">1</p>
      <p class="second">2</p>
      <p class="third">3</p>
      <p class="fourth">4</p>
      <p class="fifth">5</p>
    </div>

  </body>

</html>

https://plnkr.co/edit/IoR8muSmBLtFZIXLOvPe?p=preview

© www.soinside.com 2019 - 2024. All rights reserved.