- Notes
- Bootstrap 4 requires the HTML5 doctype (<!doctype html>).
- It follows mobile first strategy, so when you develop something, then it's better to design first for the small scale device. So use responsive viewport meta tag (<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">) in head section.
- Component start with base class and extended through modifier class.
- Prefer HTML and CSS over JavaScript.
- Disable JavaScript functionality (data attribute API) use $(document).off('.data-api') or specific element use $(document).off('.miza.data-api').
- Click Events for details.
- Programmatic JavaScript API used in bootstrap for plugin which is single, chainable and returned the collection value.
- Methods can accept an optional options object.
- Visually hidden contents (like .sr-only) are visually hidden but accessible through dependable technologies for non visual users information [sr-only sr-only-focusable].
- Additional bootstrap styling is added on element for change/customize default HTML behavior is called reboot. Use classes when you need additional styling.
- 'box-sizing' is globally set on every element. So, declared elements never exceeds due to border or padding. Initial font-family:16px.
- Bootstrap uses their customized web fonts instead of default web fonts
- For easy spacing 'margin-top' is removed from heading and <p> tags. In addition, 'margin-bottom' (.5rem for headings and 1rem for paragraphs) is added.
- All lists like <ul>, <ol>, and <dl> remove 'margin-top' and added 'margin-bottom' 1rem, but nested lists have no 'margin-bottom'.
- Reset <dd> like margin-left:0; and margin-bottom: .5rem.
- Reset <dt> like margin-left:0; and margin-bottom: .5rem with bolded.
- Remove 'margin-top' and use 'margin-bottom' on <pre>.
- Tables are slightly changed, mainly additional classes are use. Remarkable change are done on 'Forms' and 'address'. Blockquote have changed margin.
- Everywhere cursor is text but pointer when element is clickable.
- For hidden use attribute hidden (<input type="text" hidden> for more accuracy.
- Responsive typography: Scaling text and components are adjusting with the root elements based on media queries. Bootstrap don't do this automatically, but can be easily added.
- Layout (Components and options inside container with grid system in responsive manner)
- Containers
- Most basic layout element.
- Inside content center in a page.
- Require when use default grid system.
- Responsive.
- Fixed or Fluid width.
- Container can be nested.
- Use .container-fluid for full width container.
- z-index
- Control third axis.
- Avoid conflicts set high and specific standard for layered components.
- Grid
- Grid system requires series of containers, rows, and columns to align and layout.
- Grid have five breakpoints.
- Container (.container or .container-fluid) provide horizontally pad and center site's content. While .container for a responsive pixel width and .container-fluid for 100% width across all viewport and device sizes.
- Row is used for column wrapping.
- Gutter horizontal padding between columns. Use .no-gutters on .row for removing margin form rows and padding from columns.
- Columns are immediate child of .row and contain within column. Columns are fluid width and maximum twelve columns are valid.
- Grid Options
- Extra Small
- <576px
- xs (col-)
- Maximum container width auto (none).
- Small
- >=576px
- sm (col-sm-)
- Maximum container width 540px.
- Medium
- >=769px
- md (col-md-)
- Maximum container width 720px.
- Large
- >=992px
- lg (.col-lg-)
- Maximum container width 960px.
- Extra Large
- >=1200px
- xl (.col-xl-)
- Maximum container width 1140px.
- Auto columns
- Like col-3 or col-sm-3 or col-md-3 or col-lg-3 or col-xl-3.
- Equal-width
- Equal width column value from xs to xl, use class .col on columns.
- Force next columns to break to new line
- Breakpoints <div class="w-100"></div>.
- Setting one column fixed width
- One column fixed size and sibling columns are automatically resize.
- .container>.row>.col+.col-6+.col
- Variable width content
- Column width adjust with columns natural content width.
- .container>.row>.col + .col-md-auto + .col .col-lg-2.
- Stacked to horizontal
- Using single set classes .col-*-*.
- Like .col-lg-4 means column acquire four columns with horizontal area when large screen, but no stack on other screen mode.
- Mix and match
- Combination of different size columns in different tires. Use multiple .row with different columns.
- Alignment
- Vertical Alignment
- Columns start from top, center or bottom.
- .container>.row .align-items-start >.col+.col+.col
- .container>.row .align-items-center >.col+.col+.col
- .container>.row .align-items-end >.col+.col+.col
- Single columns start from top, center or bottom.
- .container>.row>.col .align-self-start + .col .align-self-center + .col .align-self-end
- Horizontal Alignment
- Different type of alignment. For example,
- .container>.row .justify-content-start > .col-3 + .col-3
- .container>.row .justify-content-center > .col-3 + .col-3
- .container>.row .justify-content-end > .col-3 + .col-3
- .container>.row .justify-content-around > .col-3 + .col-3
- .container>.row .justify-content-between > .col-3 + .col-3
- Extra Column
- In a row more than twelve columns are placed then additional columns in the next line.
- Order
- Can change column order by using .order- class.
- .col .order-first/col order-last classes use for order.
- Offsetting columns in two ways
- Offset classes (like .offset-md-*).
- Margin utilities (like .mr-auto) to force sibling columns from one another.
- Nested column
- .container>.row>>.col-md-8>.row>.col-md-4+.col-md-4
- Self column
- Create and customize my new column by using bootstrap mixins
- Media object
- Design alongside and without wrap with content.
- Two classes are required for media object.
- .media class wrap the media with content
- .media-body class wrap only the content.
- .media>img+.midia-body{...}
- Media object can be infinitely nested.
- Alignment
- Media object can be aligned to the top, middle, or end of .media-body content.
- .align-self-start
- align-self-center
- align-self-end
- Order
- .media>.midia-body{...}+img.
- Media list
- ul.list-unstyled>li.media>img+.media-body
- Utilities for layout
- Showing, hiding, aligning, and space content.
- Content
- Typography
- Heading
- Classes .h1 to .h6 are available for heading without associate HTML (<p class="h2">abc</p>).
- Can customize heading.
- Display Heading
- A larger, slightly more opinionated heading style (.display-1, .display-2, .display-3, .display-4).
- <h1 class="display-1">Display</h1>
- Lead
- Make a paragraph stand out by adding .lead class.
- Inline text elements
- Reboot mark and small element with .mark and .small classes.
- <p>Back <mark>Door</mark> text.</p>
- <p><small>Small.</small></p>
- Dotted underline (abbreviation)
- Use .initialism class for small font (<p><abbr title="galib" class="initialism">GAB</abbr></p>).
- Blockquotes (block of content from another source)
- <blockquote class="blockquote"> <p class="mb-0">...</p></blockquote>
- Writer name/naming source
- <blockquote class="blockquote"> <p >...</p> <footer class="blockquote-footer">You <cite title="Source Title">Galib</cite></footer></blockquote>
- Text center/right
- <blockquote class="blockquote text-center/text-right"> <p >...</p> <footer class="blockquote-footer">You <cite title="Source Title">Galib</cite></footer></blockquote>
- Lists
- .list-unstyled for unordered list with margin modification.
- Inline arrangement requires two classes. Like ul.list-inline>li.list-inline-item.
- Responsive typography
- Scaling text and components are adjusting with the root elements based on media queries. Bootstrap don't do this automatically, but can be easily added.
- Programming code and mathematical terms in Bootstrap
- Snippets
- Wrap inline snippets with <code>.
- <code><h6></code>.
- Code blocks
- Use <pre> for block of code.
- <pre class="pre-scrollable"><code> <p>Excellent.</p> <p>Programming Tricks </p> </code></pre>
- Variables
- a = b + c; Like <var>a</var> = <var>b</var> + <var>c</var>.
- User command input
- Very nice looking user comment styling. Use simply <kbd><kbd>Alt</kbd> + <kbd>,</kbd></kbd>.
- Sample output
- Use <samp> for indicating sample output.
- Images
- Create responsive image using .img-fluid. .img-fluid's automatically set width as 100% and fit with parent width size. Also, auto is applied on height.
- <img src="..." class="img-fluid">
- Use .img-thumbnail for image with border.
- Aligning image
- <img src="..." class="rounded float-left/right" alt="...">
- <img src="..." class="rounded mx-auto d-block" alt="...">
- div.text-center>img.
- Picture
- Use .img-* class on img tag not picture tag.
- Tables
- table.table>caption+thead+tbody
- inside thead -> thead>tr>th.col
- inside tbody-> tbody>tr>th.row+th
- Classes:
- <table>: .table, .table-dark, .table-striped, .table-bordered, .table-borderless, .table-hover, .table-sm(reduce padding),
- <thead>: .thead-dark, .thead-light,
- <tr>: .table-active, .table-primary .table-secondary, .table-success, .table-danger, .table-warning, .table-info, .table-light, .table-dark, bg-primary, .bg-success, .bg-warning, .bg-danger, .bg-info.
- <th>/<td>: .table-active, .table-primary .table-secondary, .table-success, .table-danger, .table-warning, .table-info, .table-light, .table-dark, bg-primary, .bg-success, .bg-warning, .bg-danger, .bg-info.
- Make responsive table for vertically scroll
- div.table-responsive{-sm|-md|-lg|-xl}>table.table>...
- Figures with caption
- figure.figure>img.figure-img.img-fluid.rounded + figcaption.figure-caption.
- Components
- Alerts
- Text alert or close button not like javaScript alert box.
- Structure: <div class="alert alert-*" role="alert">...</div> //Alert background color alert-*->.
- With link: <div class="alert alert-info" role="alert">Alert text <a href="#" class="alert-link">With link</a></div>.
- Text alert color background
- Conveying meaning for visual indication not be conveyed to assistive technology. For user assistive technology use .sr-only.
- Classes : .alert-primary, .alert-secondary, .alert-success, .alert-danger, .alert-warning, .alert-info, .alert-light, .alert-dark.
- Additional content
- Can use heading, paragraph and/or divider in alert.
- Add class .alert-heading with h1-h6.
- <hr> of divider and p for paragraph.
- Close button or dismiss alert button can be added.
- Use JavaScript code without using css classes.
- Badges
- Small count or labeling component. Also, used in button.
- Badges size match with its parent element.
- Style classes: 8 types of visual indication color classes (badge-primary, badge-*).
- Structure sample: <p>EPT <span class="badge badge-primary">New</span></p>
- Rounded badge
- <span class="badge badge-pill badge-primary">Galib</span>
- Link
- <a href="#" class="badge badge-primary">Link</a>
- Use color scheme for hover effect.
- Breadcrumb
- Current page location with navigation hierarchy.
- Structure: nav[aria-label=breadcumb]>ol.breadcumb>(li.breadcumb-item>a{home})+li.breadcumb-item.active[aria-current=page]{About}.
- Change separator: $breadcrumb-divider: quote(">").
- Buttons
- <button type="button" class="btn btn-primary">Primary</button>
- 9 style classes are used in button (btn-*). Additional class like .btn-link is used for link purpose.
- Structure
- Class .btn are use for button with <button>, <input> or <a> tag. Add role (role="button") when use <a> tag.
- Remove image or background and add outline
- Classes: btn-outline-primary, btn-outline-secondary, btn-outline-success, .btn-outline-danger, btn-outline-info, btn-outline-light, btn-outline-dark.
- Size
- Small or large: .btn-lg or.btn-sm.
- Block level button
- <button class="btn btn-primary btn-sm btn-blokc">abc</button>.
- Active button
- <a href="#" class="btn btn-primary btn-lg active" role="button" aria-pressed="true">Primary link</a>
- Disable state
- <button type="button" class="btn btn-lg btn-primary" disabled>Button</button>
- Include aria-disabled="true" attribute and not valid in <a>.
- <a href="#" class="btn btn-primary btn-lg disabled" tabindex="-1" role="button" aria-disabled="true">Primary link</a>
- Group button
- Group buttons + Single line.
- Role can be group or toolbar (set of groups).
- Wrap buttons with .btn-group class.
<div class="btn-group" role="group" aria-label="Basic example">
<button type="button" class="btn btn-secondary">Left</button>
<button type="button" class="btn btn-secondary">Middle</button>
<button type="button" class="btn btn-secondary">Right</button>
</div>- Combine set of buttons use role="toolbar".
- div.btn-toolbar[role=toolbar,aria-label=abc]>(div.btn-group[role=group]>button.btn.btn-primary.mr-2{Primary})+div.btn-group[role=group]>button.btn.btn-info{Info}
- Input group
- In get of group items (role=toolbar) you can add input element with prepend item if required.
- Size
- Button large size: btn-group-lg.
- Medium no class.
- Button small size: btn-group-sm.
- Nesting is possible in button group.
- Add .btn-group-vertical class for vertically stacked.
- Single content container - Cards
- No margin by default.
- Basic Structure
- .card>img.card-img-top+card-body>h*.card-title+p.card-text
- Width
- It has no specific width. It inherit width for its parent(100%) unless width is specified.
- Use parent grid class(col-*) for maintain width or specified width.
- .card-body
- .card-body class use for building block.
- Use only when padding section is required inside body.
- Title, text, and links (inside .card-body)
- .card-title: Mainly used for title to a h* tag.
- .card-subtitle: Act like subtitle mainly with to a h* tag.
- .card-text: Mainly used for description like p tag.
- .card-link: For link.
- Images
- Basically image caps.
- .card-text: Can be added with image.
- Image Caps
- Body combine with image.
- .card-img-top: Place image to the top of the card.
- .card-img-bottom: Place image to the bottom of the card.
- Structure: .card>img.card-img-top+card-body>h*.card-title+p.card-text
- Image Card Background and Overlay
- Styling required or not required.
- Classes:
- .card-img
- .card-img-oberlay instead .card-body
- Structure: .card.bg-dark.text-white>img.card-img+.card-img-overlay
- List Group
- Structure: .card>.card-header+(ul.list-group.list-group-flush>li.list-group-item)
- Kitchen sink - Mix with image, body (heading, subheading, text), List Group, body(link).
- Header and footer Caps
- .card-header: An optional header with div or h*.
- .card-footer: An optional footer with div or h*.
- Different type of nonresponsive arrangements
- Card groups
- Card decks
- Card columns
- Carousel
- Slideshow + Cycle.
- Can't be nested. Class .active is mandatory.
- https://getbootstrap.com/docs/4.1/components/carousel/
- Collapse/Accordion
- Dropdowns
- Works on click not hover.
- Basic structure: .dropdown>.dropdown-toggle#myID[aria-haspopup=true][aria-expanded=false]+.dropdown-menu[aria-labelledby=myID]>.dropdown-item
- Sample: .dropdown>button#myDropDownID.btn.dropdown-toggle[type=button]{Click}+.dropdown-menu[aria-labelledby=myDropDownID]>a.dropdown-menu*4
- For drop left/right
- .dropleft/.dropright
- Dropdown divider: <div class="dropdown-divider"></div>
- Forms
- Bootstrap reboot bootstrap forms fields.
- Structure: form>.form-group>label[for=myInputID]+input#myInputID.form-control+small
- Form controls
- .form-control class mainly work on input, select, and textarea.
- .form-control-file class only use on type="file".
- .form-control-readonly class only use for plain text (readonly) with more styling.
- .form-control-range class only use for range value.
- Form controls for checkbox and radios
- .form-check>.form-check-input#check1[type=checkbox/radio]+label.form-check-label[for=check1]
- For inline: .form-check.form-check-inlline>...
- Without labels (but add labels for assistive technology with aria-label)
- .form-check>.form-check-input.position-static#chick1[type=checkbox/radio][aria-label=...]
- Sizing/height
- .form-control-lg or .form-control-sm are used for adjust height with input, select, and textarea. If you don't use this class it is adjust with middle height.
- Readonly
- No additional class is required boolean attribute is modified for prevent modification input value.
- Layout
- Display: block; width: 100%; Stack vertically. Additional class.
- .form-group class is the easiest way to add structure.
- form>(.form-group>label[for=check1]+input.form-control#check1[type=text])*4
- Grid
- General grid: form>.row>.col-*>input.form-control[type=text]
- Overrides column glitter: form>.form-row>col-*>input.form-control[type=text]
- Layout + Grid
- form>.form-row>.form-group.col-md-6>...
- Horizontal Gird
- form>.row.form-group>...
- Input Group (prepend/append)
- .input-group>.input-group-prepend>input-group-text+input
- Jumbotron
- .jumbotron>h1+p+hr+p+h6
- .jumbotron>.container>...
- List Groups
- Basic structure: ul.list-group>li.list-group-item.active+li.list-group-item+li.list-group-item.disabled
- Link or buttons - actionable list group items with hover, disabled, and active state with class .list-group-item-action.
- Structure: .list-group>a.list-group-item.list-group-item-action.active.
- Use .disable on list or anchor, Use disable attribute on buttons.
- Remove border - .list-group-flush
- <ul class="list-group list-group-flush">
- List item colors: list-group-item-*
- <ul class="list-group list-group-flush list-group-item-primary">
- Can use badge pill.
- Modal
- Nav VS Navbar
- Very similar but different.
- Nav start with base class .nav. Navbar start with base class .navbar.
- Nav use for building navigation components.
- Basically Navbar is a navigation header.
- Nav
- Use role if nav is using for navigation bar.
- .nav class not accept .active state.
- Basic structure:
- ul.nav>li.nav-item>a.nav-link
- (nav/div).nav>(a).nav-item.nav-link
- (nav/div).nav>(a).nav-link
- Place center: .justify-content-center; Right: .justify-content-end.
- Vertical/Stack navigation:
- .flex-column
- Responsive version: .flex-column-*
- Tabs: <ul class="nav nav-tabs">
- Pills: <ul class="nav nav-pills">
- Fill and justify (force to extent full): <ul class="nav nav-pills nav-fill">
- Horizontal space is occupied but items size may be differ.
- Justify: <nav class="nav nav-justified">
- Active: <a class="nav-link active" href="#">...</a>
- Disable: <a class="nav-link disabled" href="#">...</a>
- Tabs/pills with dropdown
- ul.nav.nav-tabs/.nav-pills>li.nav-item(>a.nav-link)+li.drodown(...)+li.nav-item(>a.nav-link)
- Tabs/Pills Content
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
</div>- Navbar
- .navbar-expand{-sm|-md|-lg|-xl} is used for responsive collapsing.
- Navbar requires wrap wih .navbar and .navbar-expand-*.
- By default navbar and their contents are fluid.
- Navbars are hidden when printing. Class .d-print is required for print with .navbar.
- Tag <nav> is used for navbar add role="navigation" if <div> tag is used.
- Supported content
- .navbar>.navbar-brand: Company/product name.
- .navbar>.collapse+.navbar-collapse: Grouping and hiding inside dropbox.
- .navbar>.collapse+.navbar-collapse>.nav-bar: Full-height and lightweight.
- .navbar>button.navbar-toggle: Toggle button.
- .navbar>button.navbar-toggle>.navbar-toggler-icon: Toggle icon.
- .navbar-text: Text inside navbar.
- .form-inline: Form inside navbar.
- Color
- .navbar-dark or .navbar-light + if you reuired customize with bg-*.
- Placement
- Navbars is a non-static position.
- <nav class="navbar fixed-top">
- <nav class="navbar fixed-bottom">
- <nav class="navbar sticky-top">
- Pagination
- Use aria-label for description of the purpose.
- Structure: nav[aria-label="pages"]>ul.pagination>li.page-item>a.page-link
- Can use icons in pagination box.
- Active:...>li.page-item.active>a.page-link.
- Disable: ...>li.page-item.disabled>a.page-link.
- Sizing: .pagination-lg, .pagination-sm.
- Alignment:
- Left: Default.
- Center: nav[aria-label="pages"]>ul.pagination.justify-content-center>...
- Right: nav[aria-label="pages"]>ul.pagination.justify-content-end>...
- Popovers/Dialog box
- <button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="top" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."> Popover </button>
- Progress bar/Range
- .progress>.progress-bar[role=progressbar][aria-valuenow=0][aria-valuemin=0][aria-valuemax=100]
- Scrollspy
- Mainly work on nav components or list group.
- Tooltips
- Utilities
- Borders
- Add border
- <div class="border"></div>
- .border-top, .border-right, .border-bottom, .border-left.
- Remove border
- .border-0, .border-top, .border-right, .border-bottom, .border-right.
- Border color
- class="border border-primary"
- Border-radius/Border-shape
- <div class="border rounded">...</div>
- classes: .rounded, .rounded-top, .rounded-right, .rounded-bottom, .rounded-left, .rounded-circle, .rounded-0.
- For image use only shape classes (<img class="rounded">).
- Clearfix
- Within a container clear floated content.
- Add .clearfix to the parent element.
- Close icon
- <button type="button" class="close" aria-label="Close"> <span aria-hidden="true">×</span></button>
- Color
- For anywhere, combination with background color(mainly transparent bg) and color (13).
- .text-primary, .text-secondary, .text-success, .text-danger, .text-warning, .text-info, .text-light, .text-dark, .text-body, .text-muted, .text-white, .text-black-50, .text-white-50.
- For background color (10)
- .bg-primary, .bg-secondary, .bg-success, .bg-danger, .bg-warning, .bg-info, .bg-light, .bg-dark, .bg-white, .bg-transparent.
- Embeds
- Responsive video/slideshow based on parent width.
- Embeds reboot directly to <iframe>, <embed>, <video>, and <object> elements.
- Parent element with class .embed-responsive .embed-responsive-* and embeds element with class .embed-responsive-item.
- * is a aspect ratio (21by9, 16by9, 4by3, 1by1).
- Explicit descendent class .embed-responsive-item for the styling with other attribute. It's not mandatory but using this class is a good practice.
<div class="embed-responsive embed-responsive-1by1">
<iframe class="embed-responsive-item" src="..."></iframe>
</div>- Display
- Combine of classes support various effects and all possible values for display.
- Breakpoints, from xs to xl.
- For xs
- .d-{value}, Like d-flex.
- For sm, md, lg, and xl
- .d-{breakpoint}-{value}.
- Suppose you set .d-lg-flex then flex is set on large screen and more large screen for xl not applicable on md.
- Hide or display elements on the device (d-none).
- Use d-print-* for print document.
- Flex
- .d-flex-* creates flexbox container and transform direct children elements into flex items.
- Direction of flex items in a flex container
- Left to right: .flex-row/.flex-*--row for horizontal direction.
- Right to left: .flex-row-reverse/.flex-*--row-reverse for opposite horizontal direction.
- Top to bottom: .flex-column/.flex-*--column for vertical direction.
- Bottom to top: .flex-column-reverse/.flex-*--column-reverse for opposite vertical direction.
- Auto margin for items
- Default: No auto margin.
- .mr-auto: Push items to right.
- .ml-auto: Push items to left.
- Justify-content
- change the alignment of flex items on the main axis.
- justify-content-*-start, .justify-content-*-end, justify-content-*-center, .justify-content-*-between, .justify-content-*-around.
- Align items
- Alignment of flex items on the cross axis (the y-axis to start, x-axis if flex-direction: column).
- .align-items-*-start, .align-items-*-end, .align-items-*-center, .align-items-*-baseline, .align-items-*-stretch.
- Align self
- Opposite of align items. Flexbox items to individually change their alignment on the cross axis (the y-axis to start, x-axis if flex-direction: column).
- .align-self-start, .align-self-end, .align-self-center, .align-self-baseline, .align-self-stretch.
- Fill
- Equal width with horizontal space.
- .flex-fill or .flex-*-fill.
- Grow
- .flex-glow-1[*] class grab available space.
- Shrink
- .flex-shrink-1[*] class create wrap new for shrink.
- Wrap
- I think here wrap means all items in a group.
- Default: No wrap. Also, you can use .flex-nowrap.
- Wrapping with .flex-wrap
- Reverse wrapping with .flex-wrap-reverse.
- .flex-wrap-* or .flex-reverse-*.
- Wrap items align
- <div class="d-flex align-content-* flex-wrap"> ...</div>
- Order
- Simply change item default position order.
- .order-[0-12] or .order-*-[0-12].
- Float
- Maintain the float behavior with below class.
- .float-left, .float-right, .float-none or float-*-*.
- Position
- Maintain the position behavior with below class.
- Position class are available but not responsive.
- .position-static, .position-relative, .position-absolute, .position-fixed, .position-sticky.
- Position Top/Bottom
- <div class="fixed-top/bottom">...</div>
- Position an element at the top/bottom of the viewport, from edge to edge.
- Sticky top
- When scroll past then osition an element at the top of the viewport, from edge to edge.
- <div class="sticky-top">...</div>
- Shadow
- Shadows are disabled in bootstrap.
- Default or .shadow-none.
- Small shadow: .shadow-sm.
- Medium shadow: .shadow.
- Large shadow: .shadow-ld.
- Sizing
- Default value: Try to fill the parent space. Class .w-auto or .h-auto act like default value.
- Classes .mw-100 and .mh-100 are use for 100% maximum width or maximum height.
- Classes .w-25, .w-50, .w-75 and .w-100 maintain the width of an element respect of 25%, 50%, 75% and 100%.
- Classes .h-25, .h-50, .h-75 and .h-100 maintain the height of an element respect of 25%, 50%, 75% and 100%.
- Spacing (width/height)
- Spacing classes are applied from min-width:0 and up with no boundary. Thus, it start from xs to xl.
- Example- .m-2 or .p-4 works for four side. Also, works for all breakpoints.
- Format:
- {property}{sides}-{size} for xs
- {property}{sides}-{breakpoint}-{size} for sm, md, lg, and xl.
- Auto
- Only works for margin.
- <div class="m-auto">...</div>
- Sample
- .ml-0, .mt-4, .p-4, .mr-sm-4, .pb-xl-3.
- Horizontal centering
- Horizontally centering fixed-width block level content.
- <div class="mx-auto" style="width: 200px;"> Centered element</div>
- Text
- Control alignment, wrapping, weight, and more.
- Text justify
- <p class="text-justify">Excellent Programming Tricks...</p>
- Left, right or center alignment with responsive breakpoints
- Text alignment classes realign text component.
- .text-left, .text-center, .text-right.
- .text-sm-*, .text-md-*, .text-lg-*, .text-xl-*.
- Accept Overflow
- Prevent text from wrapping with a .text-nowrap class.
- Override overflow text with an ellipsis (...)
- <span class="d-inline-block text-truncate" style="max-width: 50px;"> Excellent Programming Tricks</span>
- Require display: block/inline-block.
- Text transform
- All text lowercase: .text-lowercase.
- All text uppercased: .text-uppercase.
- First word capitalized: .text-capitalize.
- Font weight and italic
- <p class="font-weight-bold">Bold text.</p>
- <p class="font-weight-normal">Normal weight text.</p>
- <p class="font-weight-light">Light weight text.</p>
- <p class="font-italic">Italic text.</p>
- Monospace
- <p class="text-monospace">Galib</p>
- Vertical align
- Applicable on inline, inline-block, inline-table, and table cell.
- Select from .align-baseline, .align-top, .align-middle, .align-bottom, .align-text-bottom, and .align-text-top as needed.
- Visibility
- <div class="visible">...</div>
- <div class="invisible">...</div>
- Ref: https://getbootstrap.com/docs/4.1/
0 Comments