[Bootstrap] Horizontal alignment(text-center, d-flex, justify-content)

2022. 11. 23. 02:31·Framework | Library/Bootstrap
728x90

text-center

텍스트를 중앙에 배치하려면 상위요소에 .text-center 클래스를 추가한다.

<div class="text-center">
  <p>
    Lorem ipsum dolor sit, amet consectetur adipisicing elit. Recusandae nihil hic
    delectus excepturi ipsam reprehenderit iusto rem, quam, repellendus accusantium culpa
    reiciendis sit dolorum aut aperiam a architecto. Fuga, sit.
  </p>
</div>

 

이미지의 상위 요소에 .text-center 클래스를 추가하여 이미지를 중앙에 배치할 수도 있다.

<div class="text-center">
  <img src="images/logo.jpg" class="img-fluid" alt="로고" />
</div>

 

버튼의 부모 요소에 .text-center를 추가하면 버튼도 중앙에 배치한다.

<div class="text-center">
  <button type="button" class="btn btn-primary">Primary</button>
</div>

 

flexbox를 사용하면 그리드의 전체 열을 중앙에 배치할 수 있다.

<!--Grid row-->
<div class="row d-flex justify-content-center">
  <!--Grid column-->
  <div class="col-md-6">
    This column is centered
  </div>
  <!--Grid column-->
</div>
<!--Grid row-->

 

justify-content

<div class="d-flex justify-content-start">...</div>
<div class="d-flex justify-content-end">...</div>
<div class="d-flex justify-content-center">...</div>
<div class="d-flex justify-content-between">...</div>
<div class="d-flex justify-content-around">...</div>
<div class="d-flex justify-content-evenly">...</div>

justify-content에 대한 반응형 변형

  • .justify-content-start
  • .justify-content-end
  • .justify-content-center
  • .justify-content-between
  • .justify-content-around
  • .justify-content-evenly
  • .justify-content-sm-start
  • .justify-content-sm-end
  • .justify-content-sm-center
  • .justify-content-sm-between
  • .justify-content-sm-around
  • .justify-content-sm-evenly
  • .justify-content-md-start
  • .justify-content-md-end
  • .justify-content-md-center
  • .justify-content-md-between
  • .justify-content-md-around
  • .justify-content-md-evenly
  • .justify-content-lg-start
  • .justify-content-lg-end
  • .justify-content-lg-center
  • .justify-content-lg-between
  • .justify-content-lg-around
  • .justify-content-lg-evenly
  • .justify-content-xl-start
  • .justify-content-xl-end
  • .justify-content-xl-center
  • .justify-content-xl-between
  • .justify-content-xl-around
  • .justify-content-xl-evenly
  • .justify-content-xxl-start
  • .justify-content-xxl-end
  • .justify-content-xxl-center
  • .justify-content-xxl-between
  • .justify-content-xxl-around
  • .justify-content-xxl-evenly

'Framework | Library > Bootstrap' 카테고리의 다른 글

[Bootstrap] range  (0) 2022.11.23
[Bootstrap] Radio  (0) 2022.11.23
[Bootstrap] Toggle Switch  (0) 2022.11.23
[Bootstrap] Search(검색창)  (0) 2022.11.23
[Bootstrap] (m, p, t, b, l, r, x, y),(0, 1, 2, 3, 4, 5, auto),(n1, n2, n3, n4, n5), (xs, sm, md, lg, xl, xxl)  (0) 2022.11.21
'Framework | Library/Bootstrap' 카테고리의 다른 글
  • [Bootstrap] Radio
  • [Bootstrap] Toggle Switch
  • [Bootstrap] Search(검색창)
  • [Bootstrap] (m, p, t, b, l, r, x, y),(0, 1, 2, 3, 4, 5, auto),(n1, n2, n3, n4, n5), (xs, sm, md, lg, xl, xxl)
arajo
arajo
  • arajo
    아라 메모장
    arajo
  • 전체
    오늘
    어제
    • 분류 전체보기 (509)
      • Language (298)
        • HTML (55)
        • CSS (11)
        • JavaScript (70)
        • TypeScript (8)
        • Python (33)
        • Java (119)
        • C (0)
        • C# (2)
      • Programming (92)
        • Programming (14)
        • Web (51)
        • Apache (1)
        • MySQL (23)
        • AWS (3)
      • Framework | Library (26)
        • Framework | Library (3)
        • Vue.js (2)
        • React.js (5)
        • React Native (4)
        • Node.js (1)
        • Ajax (1)
        • Bootstrap (8)
        • Spring (1)
        • Flutter (1)
      • etc (2)
      • 휴식 (19)
        • 책 (13)
        • 일기 (5)
        • 게임 일기 (1)
      • A (71)
        • 공부 (18)
        • 기타 (6)
        • 일 (47)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    web
    HTML
    event
    Java
    리액트
    JavaScript
    TypeScript
    next.js
    MySQL
    제어문
    파이썬
    변수
    자바스크립트
    객체
    object
    CSS
    array
    react
    Python
    타입스크립트
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.1
arajo
[Bootstrap] Horizontal alignment(text-center, d-flex, justify-content)
상단으로

티스토리툴바