티스토리 뷰

Html,Css/Css

css : grid place-content

YG - 96년생 , 강아지 있음, 개발자 희망 2021. 10. 18. 20:37
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="styles.css" />
    <title>Document</title>
  </head>
  <body>
    <div class="grid">
      <div class="item1">1</div>
      <div class="item2">2</div>
      <div class="item3">3</div>
      <div class="item4">4</div>
      <div class="item5">5</div>
      <div class="item1">1</div>
      <div class="item2">2</div>
      <div class="item3">3</div>
      <div class="item4">4</div>
      <div class="item5">5</div>
      <div class="item1">1</div>
      <div class="item2">2</div>
      <div class="item3">3</div>
      <div class="item4">4</div>
      <div class="item5">5</div>
      <div class="item1">1</div>
      <div class="item2">2</div>
      <div class="item3">3</div>
      <div class="item4">4</div>
      <div class="item5">5</div>
      <div class="item1">1</div>
      <div class="item2">2</div>
      <div class="item3">3</div>
      <div class="item4">4</div>
      <div class="item5">5</div>
    </div>
  </body>
</html>

 

.grid {
  display: grid;
  grid-auto-rows: 100px;
  background-color: gray;
  gap: 5px;
  height: 100vh;
  grid-template-columns: repeat(5, 100px);
  grid-template-rows: repeat(5, 100px);
  place-content: end center;
  /*
  place-content는 
  grid의 width와는 별개로 grid 자체의 위치를 설정할 수 있다.
  수직 , 수평의 순서로 적어야 하며
  justify-content
  align-items를 한번에 쓸 수 있는 단축어이다.
  */
}

.item1 {
  background-color: aqua;
}

.item2 {
  background-color: brown;
}

.item3 {
  background-color: chocolate;
}

.item4 {
  background-color: darkgreen;
}

.item5 {
  background-color: darkmagenta;
}

 

 

 

https://developer.mozilla.org/en-US/docs/Web/CSS/place-content

 

place-content - CSS: Cascading Style Sheets | MDN

The place-content CSS shorthand property allows you to align content along both the block and inline directions at once (i.e. the align-content and justify-content properties) in a relevant layout system such as Grid or Flexbox.

developer.mozilla.org

 

 

'Html,Css > Css' 카테고리의 다른 글

scss : Scss Variables and Nesting  (0) 2021.10.19
css : grid min-content , max-content  (0) 2021.10.19
scss : Scss Extends  (0) 2021.10.18
css: grid autofill , autofit  (0) 2021.10.18
css: grid minmax()  (0) 2021.10.18
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함