What is the reasoning behind Bootstrap implementing a 0.02px variance between screen size breakpoints in its media queries?

// Tailored for extra small devices like portrait phones below 576px in width
@media (max-width: 575.98px) { ... }

// Designed for small devices such as landscape phones from 576px and above
@media (min-width: 576px) and (max-width: 767.98px) { ... }

// Optimized for medium-sized devices including tablets starting from 768px up to 991.98px
@media (min-width: 768px) and (max-width: 991.98px) { ... }

// Suitable for large devices like desktops ranging from 992px to 1199.98px
@media (min-width: 992px) and (max-width: 1199.98px) { ... }

// Ideal for extra-large devices like big desktop screens with a minimum width of 1200px
@media (min-width: 1200px) { ... }

Source of the code sample can be found at: https://getbootstrap.com/docs/4.1/layout/overview/

Why use .98px? Is it for ensuring cross-browser compatibility?

For more insights, check out: What are the rules for CSS media query overlap?

Answer №1

When dealing with two px-based @media rules, it can be challenging to make them mutually exclusive without any overlap or gap. The common workaround involves repeating the same media query twice and using the not keyword, which may not be very readable or maintainable. Additionally, the use of the < and > syntax introduced in Media Queries 4 is not yet widely supported.

One issue that arises is when a viewport matches both max-width: 576px and min-width: 576px simultaneously, resulting in conflicting styles being applied. To address this, many designers opt for min- and max- constraints with a minimal difference of 1 pixel, especially when considering high-resolution displays with non-integer pixel densities.

Cross-browser compatibility also plays a role in setting precise values for breakpoints. For example, Bootstrap uses 0.02px instead of 0.01px to work around a rounding bug in Safari that has yet to be resolved. This approach is evident in the source code starting from line 31 of _breakpoints.scss.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What could be causing the flex item to be wider than its container?

One issue that can arise when utilizing flexbox is the scenario where, as demonstrated below, the content exceeds the width of the viewport causing the flexbox items to become wider than their container. What are the factors contributing to this situat ...

What steps do I need to take in Bootstrap 5 to add a search icon to the navbar that reveals a search box beneath it when clicked?

I've made progress on the navbar design Now, I'm looking to add a search icon next to the login button. Clicking on the search icon should reveal a search box below the navbar, similar to the image shown below. My transparent navbar has a relati ...

Developing a PHP foreach loop that integrates seamlessly with a W3 responsive grid

Is there a way to generate multiple sets of three columns using w3.css and a foreach loop to fill each set with data from a sample database? Attempted code resulted in all the columns being in a single row: <?php foreach ($products as $index => $pro ...

Incorporate an image into a div element with the power of jQuery

As the user scrolls down the page, a sticky menu or floater bar appears. With the help of jQuery, I am able to apply the floater-bar class to the #menu-wrapper. My objective is to also insert an image inside an anchor tag at the same time the floater-bar ...

The checkbox appears to have selected values, yet the selected options are not visibly displayed

UPDATE I have been utilizing this specific file in order to dynamically generate a list of tags using the code provided below. import React from "react"; class TagElement extends React.Component{ updateCheck(e){ var v = (e.target. ...

Trouble displaying portrait images in CSS slideshow

My portfolio includes an image slider called wow slider, which can be found at You can view my site with the image slider on this page: http://jackmurdock.site50.net/StudioWork.hmtl While most of the galleries display portrait and landscape images correc ...

Maintaining the active state in Bootstrap, even when manually entering a URL, is essential for smooth

Check out this fully functional plnkr example: http://plnkr.co/edit/p45udWaLov388ZB23DEA?p=preview This example includes a navigation with 2 links (routing to 2 ui-router states), and a jQuery method that ensures the active class remains on the active lin ...

Restricting the number of items in each row using Flexbox while maintaining the original width of the child

Recently, I experimented with creating a layout using Flexbox. My goal was to have a parent element set to display:flex with a maximum of 7 child elements arranged in rows of 4 and 3 respectively, all centered. Here's an overview of what I attempted: ...

Tips for adjusting the size of a dropdown arrow icon

Is there a way to adjust the size of the drop-down icon using CSS? If not, I am looking to replace it with an image button. Thank you! <select> <option value="age">18</option> <option value="age"& ...

Tips for adding a space before the footer in a document

Implementing a Top Navigation Bar with grey spacing Avoid having any extra space just before the footer: Organizing my Layout File ("navigation_top" refers to the black navigation bar at the top) %body = render "navigation_top" .main-content .cont ...

Seeking assistance in incorporating an image into a drop-down menu

I am in the process of integrating a CSS based drop-down menu into my Wordpress website, and I need assistance with adding an image on the right side of my links when a user hovers over them in the menu. Below is the code I currently have, along with a ref ...

How to align radio_button_tag and label_tag side by side in Rails using Twitter Bootstrap 2?

Struggling to align the radio_button_tag horizontally with its label_tag. (Utilizing HAML) =radio_button_tag(:animal, "dog") =label_tag(:animal, "Dog") Which classes should I use for these form helpers to have them positioned side by side as shown below: ...

Tips for combining a linear-gradient and background-image on a single element:

Is it possible to apply a linear-gradient color along with a background-image on the same div element in HTML? I've been trying to achieve this but haven't been successful so far. Any suggestions would be greatly appreciated. Below is the snippe ...

Scrolling CSS Divisions Along the Horizontal Axis

.group { background: #000; margin-left: 25px; margin-right: 25px; padding: 15px; width: inherit; white-space: nowrap; overflow-x: auto; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; } .item { margin: 3px; backgro ...

Generate PHP web pages automatically

I'm seeking assistance on automating the creation of individual PHP pages. Currently, I have a page called catalog.php set up. Within catalog.php, there is an SQL query that connects to the database and retrieves specific information: $link = mysql ...

What is the best way to create a hover effect for Material Icons?

Having issues with Material Icon not displaying the specified changes when using CSS modules in my project import SettingsIcon from "@mui/icons-material/Settings"; import css from "./LandingPage.module.css"; <SettingsIcon className= ...

What are the steps to create a connect4 board featuring rounded corners and curved sides?

How can I create a Connect4 board with the exact styles and properties shown in the image? I want to achieve the curved sides effect as displayed. Can this be done using only HTML elements, or is there an easy SVG solution available? Here is my current co ...

What steps can I take to fix the issues on Safari that are being caused by three js on my website?

For my friend's birthday, I decided to surprise him by creating a web page for his online radio station. Being new to JavaScript, it was a great learning opportunity for me. After much experimenting, I finally got the page to work smoothly on desktop ...

Using CSS or Javascript, you can eliminate the (textnode) from Github Gist lists

My goal is to extract the username and / values from a series of gists on Github Gists. The challenge lies in the fact that there are no identifiable classes or IDs for the / value. https://i.stack.imgur.com/9d0kl.png Below is the HTML snippet with a lin ...

The HTML button navigates to an incorrect form

I have developed a program that includes a section for user comments and another section where logged-in users can input their own comments. When a logged-in user writes a comment, they will see a delete button next to it. Clicking on this button should t ...