Bespoke media queries spanning the entire application

Currently, I am utilizing the angular7 application along with bootstrap 4.2.1. Although Bootstrap provides numerous breakpoints, I only require three specific breakpoints for my project. To achieve this customization, I made modifications in the following way:

@import '~bootstrap/scss/_functions.scss';
@import '~bootstrap/scss/_variables.scss';
@import '~bootstrap/scss/mixins/_breakpoints';

$grid-breakpoints: (
    sm: 320px,
    md: 767px,
    lg: 1024px
);

$container-min-widths: (
  sm: 320px,
  md: 768px,
  lg: 1024px
);

@import "~bootstrap/scss/bootstrap";

@include media-breakpoint-up(lg) {
    body{
        background:green;
    }
}

@include media-breakpoint-up(md) {
    body{
        background:yellow;
    }
}

With these changes, my app now operates on only three specific breakpoints and minimum widths. However, I noticed that when I specify a class property for the md breakpoint, it also applies to the lg breakpoint. Can someone point out what might be wrong here and provide guidance on how to effectively customize the properties for the designated breakpoints?

Answer №1

While browsing through bootstrap's documentation at https://getbootstrap.com/docs/4.2/layout/overview/#responsive-breakpoints, I discovered that the term media-breakpoint-up actually refers to min-width rather than max-width.

According to the documentation:

An element is hidden starting at min-width: 0, and then shown at the sm breakpoint.

.custom-class {
  display: none;
}

@include media-breakpoint-up(sm) {
  .custom-class {
    display: block;
  }
}

In my opinion, it would be more appropriate to utilize media-breakpoint-only as suggested by Bootstrap:

There are also media queries and mixins for targeting a single segment of screen sizes using the minimum and maximum breakpoint widths.

For instance:

@include media-breakpoint-only(sm) { ... }

translates to:

@media (min-width: 576px) and (max-width: 767.98px) { ... }

Don't forget to explore media-breakpoint-between as well.

I hope this information proves helpful.

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

The system is unable to retrieve the value of the property which is set as null

I'm trying to figure out how to store the input value of name_enter into the variable userName. However, every time I attempt this, I encounter the following console error: Uncaught TypeError: Cannot read property 'value' of null function ...

setting the width to 1fr, the grid will automatically flow in columns

Can I set column width to 1fr with grid-auto-flow: column? grid-template-columns: repeat(4, 1fr) I want all columns to have the same width, based on the widest column, but so far I can only do it by specifying the number of columns: https://i.sstatic.net ...

What steps should I take to ensure proper rendering of CSS in Django?

Hey there! I'm new to Django and I'm struggling to get my css to display properly. I'm trying to create a red notification, similar to Facebook, for my unread messages. But for some reason, my css isn't rendering. Can anyone point out w ...

Tips for transferring a codepen.io example to a .vue file

A codepen.io example (https://codepen.io/srees/pen/pgVLbm) has caught my attention, and I would like to experiment with it within the framework of a .vue application I'm currently developing. However, I'm facing some difficulties transferring the ...

Incorporating PHP script within a stylesheet

Is it possible to include php code within a css file for adding conditions to css properties? styles.css <?php if($suserid == 2) { ?> .proverb { border:0px solid blue; margin-left:34px; width:250px !important; margin-top:6px; } <?php } e ...

How can jQuery determine the amount of line breaks within a div element?

My div wrap size is a percentage of the screen width, containing multiple .item divs that break into new lines as the window size decreases. I attempted to calculate the total number of boxes that could fit based on their widths compared to the container ...

Showing two hyperlinks in distinct columns within a table

I am encountering an issue with my system that showcases video tutorials. The code I have currently displays the video name (eNISATQuestion) and the video link (eNISATVideo) within one href tag. My goal is to include another column that will display a lin ...

I'm looking for a tool or plugin for webpack that can generate inline CSS directly from SASS code

Looking to generate a unique HTML code using only inline CSS. Here is the initial HTML file: <div id="highlighted">This is the highlighted text.</div> Accompanied by this Sass file: #highlighted { background: #ff0; } Now, the goal is t ...

Issues have been reported with Angular 10's router and anchorScrolling feature when used within a div that is positioned absolutely and has overflow set

I feel like I may be doing something incorrectly, but I can't quite pinpoint the issue. Any help or pointers would be greatly appreciated. My current setup involves Angular 10 and I have activated anchorScrolling in the app-routing.module file. const ...

Steps for ensuring that a script is loaded after the page has fully loaded

Is there a way to make the progress bar begin its loading animation after the `onload` loader animation has completed? Check out this example of normal progress bar animations: JSFiddle Alternatively, here is an example with the `onload` loader added: JSF ...

How to prevent page scrolling in an Android web browser

Struggling to prevent my website from scrolling on different devices. While it's relatively easy to achieve on desktop browsers using overflow: hidden;, I'm facing issues with my Android tablet where the page continues to scroll no matter what I ...

designing a white border for the webpage in HTML

As I begin my journey into HTML to secure a summer internship, I am diligently taking notes from the tutorials on HTML.net. A particular question has arisen as I delve further into CSS; how can I encase the body of my text in a white box? Having mastered ...

Remove the ahover effect on touch for iPad and iPhone devices

I have a button with a:hover effect, but I want to disable hover on iPad and iPhone. It's not working. $(document).ready(function () { $(".content").hide(); $(".open1").click(function () { $(this).next().slideT ...

What is the best way to incorporate a new attribute into a particular CSS class?

Just to provide some context, I am relatively new to all of this. Please bear with me. I have a unique CSS class that is specifically assigned to thumbnail images on my Wordpress website. Currently, I am using a script that adds a "Pin it" hover link to a ...

Creating a website that consistently functions in "lg" mode using Bootstrap

My website is fully responsive and I use the classes hidden-* and visible-* extensively. Now, I want to give mobile users the option to view the desktop version of the site by clicking on a button labeled "Desktop Website". Here are some Bootstrap tips fo ...

Allow for separation amongst my cellular components

I have a table with multiple cells and I would like to add some spacing between each <td> element. You can find an example of my code on JSFIDDLE. .line { border-bottom:1px solid black; } .textRotation { -webkit-transform: rotate(-90deg); ...

Why is my column getting devoured even though it has custom content tailored to it?

In my layout, I have one column, one row, and three nested columns. Each column contains a custom-designed button instead of using the default Bootstrap button. However, there seems to be an issue where one of the columns is getting cut off. To better und ...

Tips for Creating a Smooth Slide-Down Effect in Your Navbar Menu

Desired Outcome - My aim was to create a smooth slide down effect for the navbar after scrolling. While I managed to achieve this, I am encountering an issue. The Issue - Whenever I scroll back up to the top, the navbar becomes sticky without any transiti ...

Hide the border on a table with CSS

I recently installed a Wordpress Template and customized the table's background and text colors. However, I am struggling to remove the border around the table. Despite searching for solutions, my limited CSS knowledge has not led me to a fix that wor ...

Customizing the appearance of elements based on their designated identifier

There is a division named top nav, like this: <div id="topnav"> I want to apply styling to all the A elements within this division only, excluding those outside it. Is there a way to achieve that using CSS? ...