본문 바로가기
HTML_CSS

CSS - header 및 title,text 가운데 정렬

by le_piee 2021. 4. 30.

 

 

  <header class="welcome-header">
      <h1 class="welcome-header__title">Welcom to Clone</h1>
      <p class="welcome-header__text">
        If you have a Account, log in with your email or phone number.
      </p>
    </header>
.welcome-header {
  margin-top: 90px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-weight: 600;
}
.welcome-header__title {
  margin-bottom: 40px;
  font-size: 25px;
}
.welcome-header__text {
  width: 60%;
  opacity: 0.7;
  margin-bottom: 90px;
}

 

 

핵심코드는

 text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;

display를 flex 형태로 바꾸어 준 후

 

flex-direction을 column을 기준으로 하게 바꾸어 준 후,

align-items: center로 가운데 정렬을 합니다

 

 

 

 

 

CSS는 해도해도 어려워

'HTML_CSS' 카테고리의 다른 글

CSS - border-box 원리  (0) 2021.05.02
CSS - 상단바 깔끔하게 좌우 가운데 정렬  (0) 2021.04.29
CSS 방법론 BEM 방식  (0) 2021.04.28
CSS - Animations 예제  (0) 2021.04.18
CSS - Media Query 예제  (0) 2021.04.18