Sourced by Bootstrap
Bootstrap에는 spacing 을 편리하게 하기 위한 class들이 존재 하는데,
margin과 padding을 이용하는 것이다. (당연하지)
이것을 단축해서 사용할 수 있는데
ex) mt-0, ml-5
ex) pb-auto, pr-2
등등 이다.
차례차례 해석해 보자면
===========================================================
m- for classes that setmarginp- for classes that setpadding
m은 margin
p는 padding을 뜻한다.
===========================================================
t- for classes that setmargin-toporpadding-topb- for classes that setmargin-bottomorpadding-bottoml- for classes that setmargin-leftorpadding-leftr- for classes that setmargin-rightorpadding-rightx- for classes that set both*-leftand*-righty- for classes that set both*-topand*-bottom- blank - for classes that set a
marginorpaddingon all 4 sides of the element
t는 margin 또는 padding의 top
b는 margin 또는 padding의 bottom
l은 margin 또는 padding의 left
r은 margin 또는 padding의 right
x는 margin 또는 padding의 left와 right
y는 margin 또는 padding의 top과 bottom
공백은 margin 또는 padding의 top, bottom, left, right
를 가리킨다.
===========================================================
0- for classes that eliminate themarginorpaddingby setting it to01- (by default) for classes that set themarginorpaddingto$spacer * .252- (by default) for classes that set themarginorpaddingto$spacer * .53- (by default) for classes that set themarginorpaddingto$spacer4- (by default) for classes that set themarginorpaddingto$spacer * 1.55- (by default) for classes that set themarginorpaddingto$spacer * 3auto- for classes that set themarginto auto
0~5까지 숫자가 있고
각 숫자는 전체 box의 크기를 기반으로 margin 또는 padding에 0.25 * (숫자) 만큼 할당해 준다.
auto는 margin만 auto로 한다. padding은 auto가 되지 않는다고 한다. (기본 css문법에서도 그렇다.)
padding은 auto쓰고 싶으면 그냥 0으로 두고 margin만 건드는 것을 추천.
===========================================================
아래는 실제로 css에서 어떻게 구현되어 있는지 보여준다.
.mt-0 {
margin-top: 0 !important;
}
.ml-1 {
margin-left: ($spacer * .25) !important;
}
.px-2 {
padding-left: ($spacer * .5) !important;
padding-right: ($spacer * .5) !important;
}
.p-3 {
padding: $spacer !important;
}===========================================================
그리고 bootstrap에서 나오는 마지막 꿀팁
Additionally, Bootstrap also includes an .mx-auto class for horizontally centering fixed-width block level content—that is, content that has display: block and a width set—by setting the horizontal margins to auto.
<div class="mx-auto" style="width: 200px;">
Centered element
</div>'개발 > Web Programming' 카테고리의 다른 글
| 웹프로그래밍 하면서 너무 화나는 점. (1) | 2019.03.06 |
|---|---|
| [Bootstrap] Float (0) | 2019.03.05 |
| [Bootstrap] table정리 (0) | 2019.03.05 |
| [Bootstrap] 버튼/button/btn 정리 (0) | 2019.03.04 |
| [Bootstrap] sr-only는 뭘까? (what is sr-only) (2) | 2019.03.03 |