Bootstrap Basics #2
Text Colors
Bootstrap 4 has some contextual classes that can be used to provide "meaning through colors".
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
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.
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.
Bootstrap 4 Images
Rounded Corners
The .rounded
class adds rounded corners to an image
Example :
<img src="cinqueterre.jpg" class="rounded" alt="Cinque Terre">
Circle
The .rounded-circle
class shapes the image to a circle
Example :
<img src="cinqueterre.jpg" class="rounded-circle" alt="Cinque Terre">
Thumbnail
The .img-thumbnail
class shapes the image to a thumbnail (bordered)
Example:
<img src="cinqueterre.jpg" class="img-thumbnail" alt="Cinque Terre">
Centered Image
Center an image by adding the utility classes .mx-auto
(margin:auto) and .d-block
(display:block) to the image
Example :
<img src="paris.jpg" class="mx-auto d-block">
Responsive Images
Images come in all sizes. So do screens. Responsive images automatically adjust to fit the size of the screen.
The .img-fluid
class applies max-width: 100%;
and height: auto;
to the image
Example:
<img class="img-fluid" src="img_chania.jpg" alt="Chania">
Bootstrap 4 Buttons
Button Styles
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-secondary">Secondary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button type="button" class="btn btn-warning">Warning</button>
<button type="button" class="btn btn-danger">Danger</button>
<button type="button" class="btn btn-dark">Dark</button>
<button type="button" class="btn btn-light">Light</button>
<button type="button" class="btn btn-link">Link</button>
<a>
, <button>
, or <input>
elements.Button Outline
Bootstrap 4 provides eight outline/bordered buttons.
Example:
<button type="button" class="btn btn-outline-primary">Primary</button>
<button type="button" class="btn btn-outline-secondary">Secondary</button>
<button type="button" class="btn btn-outline-success">Success</button>
<button type="button" class="btn btn-outline-info">Info</button>
<button type="button" class="btn btn-outline-warning">Warning</button>
<button type="button" class="btn btn-outline-danger">Danger</button>
<button type="button" class="btn btn-outline-dark">Dark</button>
<button type="button" class="btn btn-outline-light text-dark">Light</button>
Button Sizes
Use the .btn-lg
class for large buttons or .btn-sm
class for small buttons.
Example:
<button type="button" class="btn btn-primary btn-lg">Large</button>
<button type="button" class="btn btn-primary">Default</button>
<button type="button" class="btn btn-primary btn-sm">Small</button>
Block Level Buttons
Add class .btn-block
to create a block level button that spans the entire width of the parent element.
Example:
<button type="button" class="btn btn-primary btn-block">Full-Width Button</button>
Active/Disabled Buttons
A button can be set to an active (appear pressed) or a disabled (unclickable) state
Example:
<a href="#" class="btn btn-primary disabled">Disabled Link</a>
Spinner Buttons
<span class="spinner-border spinner-border-sm"></span>
</button>
<button class="btn btn-primary">
<span class="spinner-border spinner-border-sm"></span>
Loading..
</button>
<button class="btn btn-primary" disabled>
<span class="spinner-border spinner-border-sm"></span>
Loading..
</button>
<button class="btn btn-primary" disabled>
<span class="spinner-grow spinner-grow-sm"></span>
Loading..
</button>
Bootstrap 4 Button Groups
<button type="button" class="btn btn-primary">Apple</button>
<button type="button" class="btn btn-primary">Samsung</button>
<button type="button" class="btn btn-primary">Sony</button>
</div>
.btn-group-lg
for a large button group or the .btn-group-sm
for a small button group..btn-group-vertical
to create a vertical button group.Bootstrap 4 Progress Bars
.progress
class to a container element and add the .progress-bar
class to its child element. Use the CSS width
property to set the width of the progress bar<div class="progress-bar" style="width:70%"></div>
</div>
Progress Bar Labels
Add text inside the progress bar to show the visible percentage.
Example:
<div class="progress">
<div class="progress-bar" style="width:70%">70%</div>
</div>
Colored Progress Bars
Example:
<!-- Blue -->
<div class="progress">
<div class="progress-bar" style="width:10%"></div>
</div>
<!-- Green -->
<div class="progress">
<div class="progress-bar bg-success" style="width:20%"></div>
</div>
<!-- Turquoise -->
<div class="progress">
<div class="progress-bar bg-info" style="width:30%"></div>
</div>
Light grey text.
Comments
Post a Comment