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

CSS align-items 속성 중심 값 사용

<시간/>

항목 정렬 사용 가치가 있는 속성 중심 플렉스 항목을 중앙에 정렬합니다.

다음 코드를 실행하여 중심 값을 구현할 수 있습니다.

예시

<!DOCTYPE html>
<html>
   <head>
      <style>
         .mycontainer {
            display: flex;
            background-color: orange;
            align-items: center;
            height: 150px;
            width: 600px;
         }
         .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>Q1</div>
         <div>Q2</div>
         <div>Q3</div>
         <div>Q4</div>
      </div>
   </body>
</html>