You can use classes overflow-hidden or overflow-auto to quickly define how the contents overflows from an HTML element. You must define the element's height though.
<div class="content overflow-hidden"></div>
Bootstrap 4 also offers classes for positioning of an HTML element quickly. You can use any of the classes listed below to define positioning of an element.
<div class="position-static">...</div> <div class="position-relative">...</div> <div class="position-absolute">...</div> <div class="position-fixed">...</div> <div class="position-sticky">...</div> <div class="fixed-top">...</div> <div class="fixed-bottom">...</div> <div class="sticky-top">...</div>
You can use class sr-only to display some content only for screen readers. You can also use class sr-only-focusable with the sr-only class to make contents appear while on focus.
Bootstrap 4 also offers utility classes to add or remove box shadows to/from an HTML element which can be used with responsive variants too.
<div class="shadow-none">No shadow</div> <div class="shadow-sm">Small shadow</div> <div class="shadow">Regular shadow</div> <div class="shadow-lg">Larger shadow</div>
Bootstrap 4 also offers classes to define width and height of an HTML element quickly and easily. Available classes to define width are as follows.
Available classes to define height are as follows.
You can also define the max width or max height of an HTML element with classes mw-100 and mh-100.
You can also use utilities to set the width and height of any HTML element relative to the viewport.
Bootstrap 4 includes a wide range of margin and padding utility classes to define an element’s appearance. All of them support their responsive variants from xs to xl too where the spacing is the multiple of 1rem which the default font size of the document.
The classes are named using the format {property}{sides}-{size} for xs and {property}{sides}-{breakpoint}-{size} for sm, md, lg, and xl.
Property Options are as follows.
Options for sides are as follows.
Options for the spacing size are as follows.
You can also add negative margin using class format {property}{sides}-n{size} or {property}{sides}-{breakpoint}-n{size}.
Horizontally Centered Element
You can use class mx-auto to center an HTML element horizontally.
<div class="mt-0"></div> <div class="my-3"></div> <div class="px-2"></div> <div class="pb-5"></div>
You can make an entire div clickable by adding class stretched-link to its child anchor tag. Position and z-index might need to be added sometimes to make it work properly.
<div class="w-50 p-2 shadow-sm bg-dark text-light"> <h4>Content Heading</h4> <p class="text-justify">Lorem ipsum dolor sit amet...</p> <a href="#" class="stretched-link">Read more »</a> </div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Read more »Bootstrap 4 includes a wide range of text utility classes to define their alignment, wrapping, transform, weight, etc.
You can align texts using bootstrap 4 easily with these utility classes.
You can also use their responsive variants like text-sm-left.
You can force or remove text wrapping using utility classes text-wrap or text-nowrap.
You can also truncate a text adding ellipsis at the end using utility class text-truncate.
<div class="w-50 text-truncate"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt. </div>
You can break a long word using class text-break in order to prevent it from breaking your layout.
<div class="w-25 text-break"> bfkdaodfnaodbfadfasbdpfbksdbkfjbabdsfadbkfabk </div>
You can change the text capitalization using text transformation utilities as shown below.
<p class="text-lowercase">LOWERED SENTENCE CASE</p> <p class="text-uppercase">uppered sentence case</p> <p class="text-capitalize">capitalized text</p>
LOWERED SENTENCE CASE
uppered sentence case
capitalized text
You can use font utilities to change the weight of the text or italicize them. You can also set the font family to
<p class="font-weight-bold">Bold text.</p> <p class="font-weight-bolder">Bolder weight text.</p> <p class="font-weight-normal">Normal weight text.</p> <p class="font-weight-light">Light weight text.</p> <p class="font-weight-lighter">Lighter weight text.</p> <p class="font-italic">Italic text.</p>
Bold text.
Bolder weight text.
Normal weight text.
Light weight text.
Lighter weight text.
Italic text.
You can change the font family of a text to monospace using class text-monospace.
<p class="text-monospace">This is in monospace</p>
This is in monospace
You can use class text-reset to reset the text color of any text or link.
You can also use class text-decoration-none to remove text decoration from a link.
You can set the visibility of the element using classes visible or invisible easily with bootstrap 4.
0 Comment
Leave a comment