갈푸라떼
갈푸라떼는 개발중
갈푸라떼
전체 방문자
오늘
어제
  • 분류 전체보기 (232)
    • CS (0)
      • CSinfo (0)
    • Frontend (15)
      • HTML,CSS (1)
      • Javascript (2)
      • React (0)
      • React Hook (12)
    • Backend (0)
      • Python (0)
      • Node.js (0)
      • php (0)
    • DB (2)
      • MySQL (2)
      • BigQuery (0)
      • Mongodb (0)
    • Study (186)
      • JavaScript (72)
      • JavaScript(Clean code) (50)
      • Node.js (11)
      • HTML,CSS (13)
      • React (30)
      • TypeScript (10)
      • React-Native (0)
    • Error (2)
      • error (2)
    • Git (22)
      • Git (22)
    • Help Coding (4)
      • Useful websites (3)

블로그 메뉴

  • 홈
  • 태그
  • 방명록
  • Github

공지사항

인기 글

태그

  • 네이밍
  • PM2
  • 이터러블
  • SPREAD
  • structure
  • 상속
  • 호이스팅
  • class
  • 스코프 체인
  • 인터프리터
  • 객체타입
  • 원시타입
  • 렉시컬 환경
  • 싱글스레드
  • 자바스크립트엔진
  • 심볼
  • symbol
  • 정적 레벨
  • ECMAScript
  • prototype
  • this
  • 함수
  • function
  • Arrow
  • Babel
  • nodemon
  • 오버라이딩
  • 실행 컨텍스트
  • 컴파일러
  • 프로토타입

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
갈푸라떼

갈푸라떼는 개발중

[CSS_study] display : grid_7 minmax & min-content & max-content
Study/HTML,CSS

[CSS_study] display : grid_7 minmax & min-content & max-content

2022. 5. 18. 00:32

* minmax(min, max)

  • element가 가능한 한 엄청 크길 원하는데, 동시에 엄청 작게 되는것은 원치 않을 때

ex) grid-template-columns: repeat(5, minmax(100px, 1fr));
- 최소 100px, 최대 1fr

 

* max-content

  • content의 크기만큼 cell의 크기를 늘린다.

* min-content

  • content의 크기를 최대한 줄여 cell의 크기를 줄인다.


어떻게 content가 보여야 하는지 디자인하는 것이다.
(참고) repeat(), auto-fit, auto-fill, minmax와 결합하여 반응형 디자인을 만들 수 있다.


* min-content & max-content 예시 코드

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="test.css" />
  </head>
  <body>
    <div class="grid">
      <div class="item">This is a very long text</div>
      <div class="item">This is a very longer longer long text</div>
      <div class="item">This is a text</div>
      <div class="item">
        Not long at all, or maybe, who knows? Maybe you know, love you.
      </div>

      <div class="item">This is a very longer long text</div>
      <div class="item">This is a very longer long text</div>
      <div class="item">This is a very longer long text</div>
      <div class="item">This is a very longer long text</div>
    </div>
  </body>
</html>

 

.grid {
  color: white;
  display: grid;
  gap: 5px;
  grid-template-columns: min-content max-content;
  grid-auto-rows: 100px;
  margin-bottom: 30px;
}

.item:nth-child(odd) {
  background-color: #2ecc71;
}

.item:nth-child(even) {
  background-color: #3498db;
}

 

'Study > HTML,CSS' 카테고리의 다른 글

[CSS_study] display : grid_8 auto-fit & auto-fill  (0) 2022.05.18
[CSS_study] display : grid_6 place-self & auto columns and rows  (0) 2022.05.17
[CSS_study] display : grid_5 place-items & place-content  (0) 2022.05.17
[CSS_study] display : grid_4 grid-template & fr (fraction)  (0) 2022.05.17
[CSS_study] display : grid_3 (Line Naming)  (0) 2022.05.14
    'Study/HTML,CSS' 카테고리의 다른 글
    • [CSS_study] display : grid_8 auto-fit & auto-fill
    • [CSS_study] display : grid_6 place-self & auto columns and rows
    • [CSS_study] display : grid_5 place-items & place-content
    • [CSS_study] display : grid_4 grid-template & fr (fraction)
    갈푸라떼
    갈푸라떼

    티스토리툴바