Computer >> 컴퓨터 >  >> 프로그램 작성 >> CSS

CSS를 사용하여 나머지 플렉스 항목에 비해 플렉스 항목이 얼마나 커질 것인지 설정

<시간/>

flex-grow 속성을 사용하여 플렉스 항목의 크기를 늘립니다. 하나 이상의 플렉스 아이템과 함께 사용하세요.

예시

다음 코드를 실행하여 flex-grow 속성을 구현할 수 있습니다. 여기 Q3 플렉스 아이템이 다른 아이템보다 큽니다 -

<!DOCTYPE html>
<html>
   <head>
      <style>
         .mycontainer {
            display: flex;
            background-color: orange;
            align-content: space-between;
         }
         .mycontainer > div {
            background-color: white;
            text-align: center;
            line-height: 40px;
            font-size: 25px;
            width: 100px;
            margin: 5px;
         }
      </style>
   </head>
   <body>
      <h1>Quiz</h1>
      <div class = "mycontainer">
         <div style = "flex-grow: 1">Q1</div>
         <div style = "flex-grow: 1">Q2</div>
         <div style = "flex-grow: 20">Q3</div>
         <div style = "flex-grow: 1">Q4</div>
         <div style = "flex-grow: 1">Q5</div>
      </div>
   </body>
</html>