Utilizing Bootstrap 3.0 Media Queries for Responsive Design

Currently, I am working on a small project utilizing Boostrap 3 (html5boilerplate custom build) and attempting to incorporate the "official" media queries as outlined in the Bootstrap documentation:

/* Extra small devices (phones, up to 480px) */
/* No media query since this is the default in Bootstrap */

/* Small devices (tablets, 768px and up) */
@media (min-width: @screen-sm) { ... }

/* Medium devices (desktops, 992px and up) */
@media (min-width: @screen-md) { ... }

/* Large devices (large desktops, 1200px and up) */
@media (min-width: @screen-lg) { ... }

However, it appears that the media queries (@screen-sm, screen-md, screen-lg) do not seem to be recognized. Despite searching through the Bootstrap files, I am unable to locate any references.

In my sample code (main.css):

/* Small devices (tablets, 768px and up) */
@media (min-width: @screen-sm) {

    .header-btn {display: none;}

}

/* Medium devices (desktops, 992px and up) */
@media (min-width: @screen-md) {

    .slogan {display: none;}
}

/* Large devices (large desktops, 1200px and up) */
@media (min-width: @screen-lg) {}

As of now, nothing seems to be happening!

Upon checking in Chrome, I encountered the following errors:

Do you have any insights or suggestions regarding this issue?

Answer №1

The bootstrap documentation may not provide the clearest explanations.

When utilizing the @... parameters for min-width, it is important to note that this is actually a form of less syntax rather than traditional CSS.

For defining the values of these screen-xxx parameters, it is recommended to utilize the customization tool in Bootstrap (refer to Media queries breakpoints). For instance, you can set screen-sm to be 768px using this feature.

Upon clicking the Compile button at the bottom, the less code will be compiled into CSS. During this compilation process, all instances of @screen-sm will be replaced with 768px, along with any other specified parameters.

Answer №2

@adonbajrami: To incorporate your styles, make sure to include @import "myStyle.less" at the end of the bootstrap.less file.

The bootstrap.less file brings in the variables.less file. By including your custom stylesheet myStyle.less within the same parent file, you grant it access to the variables defined in variables.less.

(Apologies for not leaving a direct comment, as I'm still working on that feature.)

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

Content and form off-center when window width is limited

I am currently working on a responsive HTML page, but I am facing an issue that I cannot replicate on fiddle. To troubleshoot, I have published the page on "www.000webhost". You can access it using this link : . Kindly view it on Firefox and let me know if ...

Utilize/Absolve/Add a Prefix to angular material scss styles

Issue I am facing a challenge with integrating angular material SCSS into my application. I want to ensure that these styles are isolated and scoped specifically for my application, as it will be embedded within a larger monolith. The goal is to prevent a ...

What's the point of specifying position relative if it's not even needed?

Why do I see many sites setting the position: relative; in block elements when they do not use position in the inner elements? Is there any other reason to set the position relative? For example: <div class="parent"> <div class="parent__contai ...

Tips for showcasing numerical values using radio buttons

Hello, I am currently working on my project and have a question about calling the ajax function when clicking a button. If(isset($_POST) && ($_POST['GET_PAYMENT'] == '1')) { $totalAmount = $_POST['GET_PAYMENT']; //Total amo ...

Is it possible to automatically move text to the next line once it reaches a specific character limit using HTML/CSS/PHP?

Is there a way to handle text when it reaches the ceiling or exceeds a certain number of characters so that it goes to the next line instead of showing a scrollbar? I have a div element where I display text retrieved from a MySQL database, and sometimes th ...

Creating a Mondrian-inspired design using a combination of red, blue, and yellow within an HTML table

Is there anyone who can assist me in recreating this painting using HTML <table> tag and CSS within a browser? The image to replicate: https://i.stack.imgur.com/84y4I.jpg I attempted to complete this task, but my instructor is dissatisfied with th ...

Attempting to create a multi-page slider using a combination of CSS and JavaScript

Looking for help with creating a slider effect that is triggered when navigating to page 2. Ideally, the div should expand with a width of 200% or similar. Any assistance would be greatly appreciated! http://jsfiddle.net/juxzg6fn/ <html> <head& ...

Seamless movements to the exact midpoint

I am trying to find a method to create a smooth transition when removing the center class from p.title.class, allowing it to smoothly move to its new position. JSfiddle Here is an excerpt of my HTML: <body> <div class="wrapper-top"> ...

Display full lines of nested tree view HTML lists upon hovering using HTML, CSS, Angular, and Bootstrap

I currently have an Angular 4 application where a left-side div displays a tree of items as recursive HTML lists. The issue I am facing is that long texts within this div get cut off by the right border, with a scrollbar appearing instead. What I would lik ...

Can CSS interfere with the execution of the document ready function?

When I have a large CSS file on my page, will my document.ready execution wait for the CSS file to load? <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="large-amount-file.css"> </head ...

What could be causing the issue of node-sass generated CSS files not loading on the initial GET request?

I've set up a node express app and incorporated sass support for the CSS. However, when I attempt to access http://myhost.com:port/css/whatever.css, the whatever.css file is generated in the express_app_root/public/css directory as expected. The *.scs ...

Move a div element as you scroll down the page

I currently have a div that appears when a user scrolls down a page. When clicked, it sends you back to the top of the page. Right now, it simply fades in and out, but I would like it to slide in from the right side of the page. Below is my existing code: ...

Adding a block between two other blocks on a mobile device using Bootstrap 4

I am trying to achieve a specific layout on both desktop and mobile devices. On desktop, I want the layout to be structured as follows: [1][2] [3][2] The requirement is for column 2 to be the same height as columns 1 and 3 on desktop screens. For the mo ...

Elements generated from bootstrap's divs are not produced in a single line

I'm attempting to have a div append multiple other divs with the class "card" from Bootstrap, but instead of being created in a horizontal line, they are stacked on top of each other. I have tried to modify the "card" class by adding display: inline- ...

Dropping anchor whilst skipping or jumping

One of my website elements is a drop anchor that connects from a downwards arrow situated at the bottom of a full-page parallax image to another section on the same page. The HTML code snippet for the drop anchor is as follows: <section id="first" cla ...

Text "movement/vibration" in screen when adjusting dimensions in Firefox for Mac

I am currently involved in a project centered around showcasing a variety of fonts to users for them to experiment with, allowing them to adjust size and spacing using sliders. While the functionality works seamlessly on Chrome and Safari, a peculiar issu ...

I'm attempting to create 16 squares using bootstrap, but for some reason, it's not functioning properly and I'm unsure of

I'm struggling to create 16 squares on my website using Bootstrap, but it's not working as expected. I tried using "col-xs-3" for the width, but it's not setting correctly. Can someone please assist? PS (I know I could customize the width i ...

The collapsible navbar feature is malfunctioning and the navbar-toggle button is not responsive

Whenever I reduce the size of my browser, the collapsible navbar in Bootstrap is not visible. This is the code for my webpage: index.html <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv=" ...

What is the process for transforming a Microsoft Word HTML file into a streamlined XHTML document with inline styles?

Can someone help me with an issue I'm having regarding internal CSS? It seems that Jsoup is not able to parse the @font-face or similar elements. Any ideas on how I can clean up a Microsoft Word HTML document? ...

Tips for positioning a div next to an input box when it is in focus

I am working on a scenario where I have used CSS to extend the search box when focused. The idea is that when the search box is focused, it should decrease in size and a cancel button should appear next to it. This is the CSS code I am using: .clrble .fr ...