Bootstrap 4 အသုံးအဆောင်များ
Bootstrap 4 အသုံးအဆောင်များ
Bootstrap 4 တွင် CSS ကုဒ်ကိုအသုံးမပြုဘဲ အစိတ်အပိုင်းများကို မြန်မြန်ဆန်ဆန်စတိုင်သတ်မှတ်ရန် အသုံးဝင်မှု/အကူအတန်းများစွာရှိသည်။
နယ်နိမိတ်များ
border
ဒြပ်စင်တစ်ခုမှ ဘောင်များကို ထည့်ရန် သို့မဟုတ် ဖယ်ရှားရန် အတန်းများကို သုံး ပါ-
ဥပမာ
ဥပမာ
<span class="border"></span>
<span class="border border-0"></span>
<span class="border border-top-0"></span>
<span class="border border-right-0"></span>
<span
class="border border-bottom-0"></span>
<span class="border border-left-0"></span>
နယ်စပ်အရောင်
ဆက်စပ်ဘောင်အရောင် အတန်းအစား တစ်ခုခုဖြင့် ဘောင်သို့ အရောင်တစ်ခု ထည့်ပါ-
ဥပမာ
ဥပမာ
<span class="border border-primary"></span>
<span class="border
border-secondary"></span>
<span class="border border-success"></span>
<span class="border border-danger"></span>
<span class="border
border-warning"></span>
<span class="border border-info"></span>
<span class="border border-light"></span>
<span class="border
border-dark"></span>
<span class="border border-white"></span>
နယ်စပ်အချင်းဝက်
rounded
အတန်းများ နှင့်အတူ ဒြပ်စင်တစ်ခုသို့ အဝိုင်းထောင့်များထည့်ပါ -
ဥပမာ
ဥပမာ
<span class="rounded-sm"></span>
<span class="rounded"></span>
<span class="rounded-lg"></span>
<span class="rounded-top"></span>
<span class="rounded-right"></span>
<span
class="rounded-bottom"></span>
<span class="rounded-left"></span>
<span class="rounded-circle"></span>
<span
class="rounded-0"></span>
Float နှင့် Clearfix
.float-right
အတန်းနှင့် သို့မဟုတ် ဘယ်ဘက် တွင် ဒြပ်စင်တစ်ခုအား ညာဘက်သို့ မျှောပါ ၊ အတန်း .float-left
ဖြင့် float များကို ရှင်းလင်းပါ .clearfix
-
ဥပမာ
ဥပမာ
<div class="clearfix">
<span class="float-left">Float left</span>
<span
class="float-right">Float right</span>
</div>
တုံ့ပြန်မှု Floats
.float-*-left|right
တုံ့ပြန်မှုရှိသော float အတန်းများ ( - where * is sm
(>=576px), md
(>=768px), lg
(>=992px) သို့မဟုတ် xl
(>=1200px)) ဖြင့် စခရင်အကျယ်ပေါ်မူတည်၍ ဒြပ်စင်တစ်ခုကို ဘယ်ဘက် သို့မဟုတ် ညာဘက်သို့ မျှော ပေးပါ။
ဥပမာ
ဥပမာ
<div class="float-sm-right">Float right on small screens or wider</div><br>
<div class="float-md-right">Float right on medium screens or wider</div><br>
<div class="float-lg-right">Float right on large screens or wider</div><br>
<div class="float-xl-right">Float right on extra large screens or
wider</div><br>
<div class="float-none">Float none</div>
အလယ်တည့်တည့်
ဒြပ်စင်တစ်ခုအား .mx-auto
အတန်းအစားဖြင့် အလယ်ဗဟို (အနားသတ်-ဘယ်ဘက်နှင့် အနားသတ်-ညာကို ပေါင်းထည့်သည်- အလိုအလျောက်)-
ဥပမာ
ဥပမာ
<div class="mx-auto
bg-warning" style="width:150px">Centered</div>
အကျယ်
.w-25
w-* classes ( , .w-50
, .w-75
, .w-100
, .mw-100
) ဖြင့် element တစ်ခု၏ width ကို သတ်မှတ်ပါ ။
ဥပမာ
ဥပမာ
<div class="w-25 bg-warning">Width 25%</div>
<div class="w-50 bg-warning">Width
50%</div>
<div class="w-75 bg-warning">Width 75%</div>
<div
class="w-100 bg-warning">Width 100%</div>
<div class="mw-100 bg-warning">Max Width 100%</div>
အရပ်အမြင့်
h-* အတန်းများ ( .h-25
, .h-50
, .h-75
, .h-100
, .mh-100
) ဖြင့် ဒြပ်စင်တစ်ခု၏ အမြင့်ကို သတ်မှတ်ပါ။
ဥပမာ
ဥပမာ
<div style="height:200px;background-color:#ddd">
<div class="h-25 bg-warning">Height 25%</div>
<div class="h-50 bg-warning">Height
50%</div>
<div class="h-75 bg-warning">Height 75%</div>
<div
class="h-100 bg-warning">Height 100%</div>
<div class="mh-100 bg-warning"
style="height:500px">Max Height 100%</div>
</div>
အကွာ
Bootstrap 4 တွင် တုံ့ပြန်မှုရှိသောအနားသတ်များနှင့် padding utility အတန်းများစွာရှိသည်။ ၎င်းတို့သည် breakpoints အားလုံးအတွက် အလုပ်လုပ်သည်- xs
(<=576px), sm
(>=576px), md
(>=768px), lg
(>=992px) သို့မဟုတ် xl
(>=1200px)):
အတန်းများကို ဖော်မက်အတွက် အသုံးပြုသည်- {property}{sides}-{size}
for xs
and {property}{sides}-{breakpoint}-{size}
for sm
, md
, lg
, နှင့် xl
.
ပစ္စည်းဥစ္စာ သည် အ ဘယ်မှာ ရှိသနည်း၊
m
- အစုံmargin
p
- အစုံpadding
နှစ်ဖက်စလုံး သည် မည်သည့်နေရာတွင် ရှိသည် -
t
- အစုံmargin-top
သို့မဟုတ်padding-top
b
- အစုံmargin-bottom
သို့မဟုတ်padding-bottom
l
- အစုံmargin-left
သို့မဟုတ်padding-left
r
- အစုံmargin-right
သို့မဟုတ်padding-right
x
- နှစ်ခုလုံး နှင့်padding-left
သို့မဟုတ်padding-right
အစုံmargin-left
margin-right
y
- နှစ်ခုလုံး နှင့်padding-top
သို့မဟုတ်padding-bottom
အစုံmargin-top
margin-bottom
- blank - ဒြပ်စင်၏ 4 ဘက်စလုံးတွင် တစ်ခု
margin
သို့မဟုတ် အားလုံးကို သတ်မှတ်သည်။padding
အရွယ်အစား သည် မည်သည့်နေရာတွင် ရှိသည်
0
- အစုံmargin
ဖြစ်ဖြစ်padding
၊0
1
- သတ်မှတ်သည်margin
သို့မဟုတ် (ဖောpadding
င့.25rem
်အရွယ်အစား 16px ဖြစ်ပါက 4px)2
- သတ်မှတ်သည်margin
သို့မဟုတ် (ဖောpadding
င့.5rem
်အရွယ်အစား 16px ဖြစ်ပါက 8px)3
- ဖောင့်အရွယ်အစား သည် 16px ဖြစ်လျှင် 16pxmargin
သို့မဟုတ် သတ်မှတ်သည်)padding
1rem
4
- ဖောင့်အရွယ်အစား 16px ဖြစ်လျှင် 24pxmargin
သို့မဟုတ်padding
သတ်မှတ်သည် )1.5rem
5
- ဖောင့်အရွယ်အစားသည် 16px ဖြစ်လျှင် 48pxmargin
သို့မဟုတ်padding
သတ်မှတ်သည် )3rem
auto
margin
- အလိုအလျောက် သတ်မှတ်သည် ။
မှတ်ချက်- အရွယ်အစား ၏ ရှေ့တွင် "n" ကို ထည့်ခြင်းဖြင့် အနားသတ်များသည်လည်း အနုတ်လက္ခဏာဖြစ်နိုင်သည် ။
n1
- ဖောင့margin
်-.25rem
အရွယ်အစား 16px ဖြစ်ပါက (-4px)n2
- ဖောင့margin
်-.5rem
အရွယ်အစား 16px ဖြစ်ပါက (-8px)n3
- ဖောင့margin
်-1rem
အရွယ်အစား 16px ဖြစ်ပါက (-16px)n4
- ဖောင့margin
်-1.5rem
အရွယ်အစား 16px ဖြစ်ပါက (-24px)၊n5
- ဖောင့margin
်-3rem
အရွယ်အစား 16px ဖြစ်ပါက (-48px)
ဥပမာ
ဥပမာ
<div class="pt-4 bg-warning">I only have a top padding (1.5rem =
24px)</div>
<div class="p-5 bg-success">I have a padding on all sides
(3rem = 48px)</div>
<div class="m-5 pb-5 bg-info">I have a margin on
all sides (3rem = 48px) and a bottom padding (3rem = 48px)</div>
နောက်ထပ်အကွာအဝေးဥပမာများ
.m-# / m-*-# |
အနားသတ်အားလုံးတွင် | |
.mt-# / mt-*-# |
margin ထိပ် | |
.mb-# / mb-*-# |
margin အောက်ခြေ | |
.ml-# / ml-*-# |
အနားသတ် | |
.mr-# / mr-*-# |
margin ညာဘက် | |
.mx-# / mx-*-# |
အနားသတ် ဘယ်ညာ | |
.my-# / my-*-# |
အပေါ်နှင့်အောက်ခြေအနားသတ် | |
.p-# / p-*-# |
နှစ်ဖက်စလုံးတွင် padding | |
.pt-# / pt-*-# |
padding ထိပ် | |
.pb-# / pb-*-# |
padding အောက်ခြေ | |
.pl-# / pl-*-# |
padding ဝဲ | |
.pr-# / pr-*-# |
padding မှန်တယ်။ | |
.py-# / py-*-# |
အပေါ်နှင့်အောက်ခြေ padding | |
.px-# / px-*-# |
ဘယ်ညာ padding |
အရိပ်များ
shadow-
ဒြပ်စင်တစ်ခုသို့ အရိပ်များထည့်ရန် အတန်းများကို သုံး ပါ-
ဥပမာ
ဥပမာ
<div class="shadow-none p-4 mb-4 bg-light">No shadow</div>
<div
class="shadow-sm p-4 mb-4 bg-white">Small
shadow</div>
<div class="shadow p-4 mb-4 bg-white">Default
shadow</div>
<div class="shadow-lg p-4 mb-4 bg-white">Large
shadow</div>
ဒေါင်လိုက် ညှိပါ။
ဒြပ်စင်များ၏ ချိန်ညှိမှုကို ပြောင်းလဲရန် အတန်းများကို အသုံးပြု align-
ပါ (အင်လိုင်း၊ လိုင်း-ဘလောက်၊ လိုင်း-ဇယားနှင့် ဇယားဆဲလ်ဒြပ်စင်များပေါ်တွင်သာ အလုပ်လုပ်သည်)။
ဥပမာ
ဥပမာ
<span class="align-baseline">baseline</span>
<span
class="align-top">top</span>
<span class="align-middle">middle</span>
<span class="align-bottom">bottom</span>
<span
class="align-text-top">text-top</span>
<span
class="align-text-bottom">text-bottom</span>
တုံ့ပြန်မှု မြှုပ်နှံမှုများ
ပင်မ၏အကျယ်ကိုအခြေခံ၍ တုံ့ပြန်မှုရှိသောဗီဒီယို သို့မဟုတ် စလိုက်ရှိုးများကို ဖန်တီးပါ။
ပင်မဒြပ်စင် တစ်ခုတွင် နှင့် သင့်ရွေးချယ်မှု၏ ရှုထောင့်အချိုးအစား .embed-responsive-item
( <iframe> သို့မဟုတ် <video> ကဲ့သို့) မြှုပ်နှံထားသော မည်သည့်ဒြပ်စင်များသို့မဆို ထည့်ပါ -.embed-responsive
ဥပမာ
ဥပမာ
<!-- 21:9 aspect ratio -->
<div class="embed-responsive
embed-responsive-21by9">
<iframe class="embed-responsive-item"
src="..."></iframe>
</div>
<!-- 16:9 aspect ratio -->
<div class="embed-responsive
embed-responsive-16by9">
<iframe class="embed-responsive-item"
src="..."></iframe>
</div>
<!-- 4:3 aspect ratio -->
<div class="embed-responsive
embed-responsive-4by3">
<iframe class="embed-responsive-item"
src="..."></iframe>
</div>
<!-- 1:1 aspect ratio -->
<div class="embed-responsive
embed-responsive-1by1">
<iframe class="embed-responsive-item"
src="..."></iframe>
</div>
မြင်နိုင်စွမ်း
ဒြပ်စင်များ၏ မြင်နိုင်စွမ်းကို ထိန်းချုပ်ရန် .visible
သို့မဟုတ် အတန်းများကို အသုံးပြု ပါ။ မှတ်ချက်- ဤအတန်းများသည် CSS ပြသမှုတန်ဖိုးကို မပြောင်းလဲပါ။ သူတို့ကသာထည့် သည် သို့မဟုတ်.invisible
visibility:visible
visibility:hidden
ဥပမာ
ဥပမာ
<div class="visible">I am visible</div>
<div class="invisible">I am
invisible</div>
ရာထူး
စာမျက်နှာ၏ ထိပ်.fixed-top
တွင် မည်သည့်ဒြပ်စင်ကိုမဆို ပြုပြင်ရန်/နေရန် အတန်းကို အသုံးပြု ပါ-
ဥပမာ
<nav class="navbar navbar-expand-sm bg-dark navbar-dark fixed-top">
...
</nav>
Use the .fixed-bottom
class to make any element fixed/stay at
the bottom of the page:
Example
<nav class="navbar navbar-expand-sm bg-dark navbar-dark fixed-bottom">
...
</nav>
Use the .sticky-top
class to make any element fixed/stay at
the top of the page when you scroll past it. Note:
This class does not work in IE11 and earlier (will treat it as position:relative
).
Example
<nav class="navbar navbar-expand-sm bg-dark navbar-dark sticky-top">
...
</nav>
Close icon
Use the .close
class to style a close icon. This is often used for alerts and modals. Note that we use the ×
symbol to create the actual icon (a better looking
"x"). Also note that it floats right by default:
Example
Example
<button type="button" class="close">×</button>
Screenreaders
Use the .sr-only
class to hide an element on all devices, except screen readers:
Example
<span class="sr-only">I will be hidden on all screens except for screen
readers.</span>
Colors
As described in the Colors chapter, here is a list of all text and background color classes:
The classes for text colors are: .text-muted
,
.text-primary
, .text-success
, .text-info
,
.text-warning
, .text-danger
, .text-secondary
, .text-white
,
.text-dark
, .text-body
(default body color/often black) and .text-light
:
Example
This text is muted.
This text is important.
This text indicates success.
This text represents some information.
This text represents a warning.
This text represents danger.
Secondary text.
Dark grey text.
Body text.
Light grey text.
Contextual text classes can also be used on links, which will add a darker hover color:
Example
You can also add 50% opacity for black or white text with the .text-black-50
or .text-white-50
classes:
Example
Black text with 50% opacity on white background
White text with 50% opacity on black background
Background Colors
The classes for background colors are: .bg-primary
,
.bg-success
, .bg-info
, .bg-warning
, .bg-danger
, .bg-secondary
, .bg-dark
and .bg-light
.
Note that background colors do not set the text color, so in some cases you'll want to use them together with a .text-*
class.
Example
This text is important.
This text indicates success.
This text represents some information.
This text represents a warning.
This text represents danger.
Secondary background color.
Dark grey background color.
Light grey background color.
Typography/Text Classes
As described in the Typography chapter, here is a list of all typography/text classes:
Class | Description | Example |
---|---|---|
.display-* |
Display headings are used to stand out more than normal headings (larger font-size and lighter font-weight), and there are four classes to choose from: .display-1 , .display-2 , .display-3 , .display-4 |
|
.font-weight-bold |
Bold text | |
.font-weight-bolder |
Bolder bold text | |
.font-weight-normal |
Normal text | |
.font-weight-light |
Light weight text | |
.font-weight-lighter |
Lighter weight text | |
.font-italic |
Italic text | |
.lead |
Makes a paragraph stand out | |
.small |
Indicates smaller text (set to 85% of the size of the parent) | |
.text-break |
Prevents long text from breaking layout | |
.text-center |
Indicates center-aligned text | |
.text-decoration-none |
Removes the underline from a link | |
.text-left |
Indicates left-aligned text | |
.text-justify |
Indicates justified text | |
.text-monospace |
Monospaced text | |
.text-nowrap |
Indicates no wrap text | |
.text-lowercase |
Indicates lowercased text | |
.text-reset |
Resets the color of a text or a link (inherits the color from its parent) | |
.text-right |
Indicates right-aligned text | |
.text-uppercase |
Indicates uppercased text | |
.text-capitalize |
Indicates capitalized text | |
.initialism |
Displays the text inside an <abbr> element in a slightly smaller font size |
|
.list-unstyled |
Removes the default list-style and left margin on list items (works on both <ul> and <ol> ). This class only applies to immediate children list items (to remove the default list-style from any nested lists, apply this class to any nested lists as well) |
|
.list-inline |
Places all list items on a single line (used together with
.list-inline-item on each <li> elements) |
|
.pre-scrollable |
Makes a <pre> element scrollable |
Block Elements
To make an element into a block element, add the .d-block
class. Use any of the d-*-block
classes to control WHEN the element should be a block element on a specific screen width:
Example
Example
<span class="d-block bg-success">d-block</span>
<span class="d-sm-block
bg-success">d-sm-block</span>
<span class="d-md-block bg-success">d-md-block</span>
<span class="d-lg-block bg-success">d-lg-block</span>
<span
class="d-xl-block bg-success">d-xl-block</span>
Other Display Classes
Other display classes are also available:
Class | Description | Example |
---|---|---|
.d-none |
Hides an element | |
.d-*-none |
Hides an element on a specific screen size | |
.d-inline |
Makes an element inline | |
.d-*-inline |
Makes an element inline on a specific screen size | |
.d-inline-block |
Makes an element inline block | |
.d-*-inline-block |
Makes an element inline block on a specific screen size | |
.d-table |
Makes an element display as a table | |
.d-*-table |
Makes an element display as a table on a specific screen size | |
.d-table-cell |
Makes an element display as a table cell | |
.d-*-table-cell |
Makes an element display as a table cell on a specific screen size | |
.d-table-row |
Makes an element display as a table row | |
.d-*-table-row |
Makes an element display as a table row on a specific screen size | |
.d-flex |
Creates a flexbox container and transforms direct children into flex items | |
.d-*-flex |
Creates a flexbox container on a specific screen size | |
.d-inline-flex |
Creates an inline flexbox container | |
.d-*-inline-flex |
Creates an inline flexbox container on a specific screen size |
Flex
Use .flex-*
classes to control the layout with flexbox.
Read more about Bootstrap 4 Flex, in our next chapter.
Example
Horizontal:
Vertical: