Bootstrap 4 Media Queries Code Example


Example 1: bootstrap 4 mobile media query

// Extra small devices (portrait phones, less than 576px) @media (max-width: 575.98px) { ... }  // Small devices (landscape phones, 576px and up) @media (min-width: 576px) and (max-width: 767.98px) { ... }  // Medium devices (tablets, 768px and up) @media (min-width: 768px) and (max-width: 991.98px) { ... }  // Large devices (desktops, 992px and up) @media (min-width: 992px) and (max-width: 1199.98px) { ... }  // Extra large devices (large desktops, 1200px and up) @media (min-width: 1200px) { ... }

Example 2: bootstrap media queries

/* Large desktops and laptops */ @media (min-width: 1200px) {  }  /* Landscape tablets and medium desktops */ @media (min-width: 992px) and (max-width: 1199px) {  }  /* Portrait tablets and small desktops */ @media (min-width: 768px) and (max-width: 991px) {  }  /* Landscape phones and portrait tablets */ @media (max-width: 767px) {  }  /* Portrait phones and smaller */ @media (max-width: 480px) {  }

Example 3: bootstrap media queries

// Extra small devices (portrait phones, less than 576px) // No media query since this is the default in Bootstrap  // Small devices (landscape phones, 576px and up) @media (min-width: 576px) { ... }  // Medium devices (tablets, 768px and up) @media (min-width: 768px) { ... }  // Large devices (desktops, 992px and up) @media (min-width: 992px) { ... }  // Extra large devices (large desktops, 1200px and up) @media (min-width: 1200px) { ... }

Example 4: bootstrap media queries

/* Answer to: "bootstrap media queries" */  /*   Since Bootstrap is developed to be mobile first, the use a handful   of media queries to create sensible breakpoints for their layouts   and interfaces. These breakpoints are mostly based on minimum   viewport widths and allow scaling up elements as the viewport   changes.    Bootstrap primarily uses the following media query ranges—or   breakpoints—in their source Sass files for their layout, grid system,   and components. */  /* Extra small devices (portrait phones, less than 576px) */ /* No media query for `xs` since this is the default in Bootstrap */`32`  /* Small devices (landscape phones, 576px and up) */ @media (min-width: 576px) { ... }  /* Medium devices (tablets, 768px and up) */ @media (min-width: 768px) { ... }  /* Large devices (desktops, 992px and up) */ @media (min-width: 992px) { ... }  /* Extra large devices (large desktops, 1200px and up) */ @media (min-width: 1200px) { ... }

Example 5: bootstrap 4 media object

<div class="media">   <img class="mr-3" src="..." alt="Generic placeholder image">   <div class="media-body">     <h5 class="mt-0">Media heading</h5>     Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.   </div> </div>

Example 6: media breakpoints bootstrap 4

@include media-breakpoint-up(xs) { ... } @include media-breakpoint-up(sm) { ... } @include media-breakpoint-up(md) { ... } @include media-breakpoint-up(lg) { ... } @include media-breakpoint-up(xl) { ... }  // Example usage: @include media-breakpoint-up(sm) {   .some-class {     display: block;   } }

Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?