Apply only on small screens classes

When using desktop mode, I require the navbar to have no background color. The code for my desktop navbar is:

<nav class="navbar navbar-expand-sm">

However, on small screen devices, I need two additional classes applied to the navbar:

I need to add navbar-light and bg-light.

What steps should I take to implement this using media queries?

Answer №1

To enhance flexibility, consider assigning classes to the div and define their styles within media queries.

   <nav class="navbar navbar-expand-sm navbar-light bg-light">

    @media only screen and (max-width : 480px) {
        .navbar-light{/*customize here*/}
        .bg-light{/*customize here*/}
    }

Answer №2

To tackle your issue, utilize media queries for a responsive solution:

   <nav class="navbar navbar-expand-sm navbar-light bg-light">

    @media only screen
       and (min-device-width: 320px) 
       and (max-device-width : 480px)
        {
        .navbar-light
               {/*custom styling*/}
        .bg-light
               {/*custom styling*/}
        }

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

I am looking to automatically add a line of HTML text to the notifications list without requiring the user to manually refresh the page

Having trouble articulating the correct term or language I need, making it difficult to search. Q: How can I push a line of text from the server side to the user? I am developing an MVC 4 application using asp.net and c# in .net4. One page will feature a ...

Extracting data from websites: How to gather information from dynamic HTML elements

On the website I am exploring, there is a dynamic graph with descriptions below it that keep changing. My goal is to extract all these trajectory descriptions. The HTML code snippet related to the description area looks like this: <div class="trajDesc ...

New HTML output is displaying strangely when using jQuery AJAX

My jQuery AJAX function retrieves new HTML content from a PHP script. The PHP script is functioning correctly and sending back the accurate HTML to jQuery. However, when I utilize the html() function, the displayed HTML is incorrect. To verify the returned ...

What are the reasons behind the issues encountered when enabling "Optimization" feature in Angular that affect the proper rendering of PrimeNg elements?

Angular Version : 9.x Primeng Version : 9.x We've encountered an issue with PrimeNg elements not rendering correctly in our dev/prod environments, although they work fine in the local environment. After some investigation, we found that the culprit ...

Newbie Inquiry Renewed: What is the best way to convert this into a functional hyperlink that maintains the data received from the ID tag?

I have no prior training etc. If you are not willing to help, please refrain from responding as I am simply trying to learn here. <a id="player-web-Link">View in Depth Stats</a> This code snippet loads the following image: https://i.stack.i ...

Middle-Click JavaScript Action

On the website I'm currently working on, there is a button that uses a sprite sheet animation and therefore needs to be set as a background image. I want the button to have a slight delay when clicked, so the animation can play before redirecting to a ...

How can I optimize the display of 4 million 2D squares on a web browser?

With a display resolution of 7680x4320 pixels, I aim to showcase up to 4 million distinct colored squares. My objective is to adjust the number of squares using a slider. Currently, I have two versions in mind to achieve this goal. The first version involv ...

What steps can I take to troubleshoot when my vue.js styles are not being applied correctly?

I am trying to make these 2 styles work together <style scoped> >>> .description { white-space: nowrap !important; color: red; } >>> li a { text-decoration: none !important; } </style> Please review my code below ...

Prevent image resizing in CSS image transitions on hover within a grid layout with these helpful tips

I am looking to create a smooth image transition effect where one image transitions to another when hovered over. Currently, I have code that achieves this, but there is an issue with the initial scaling of the top image. It automatically resizes to a larg ...

Creating a responsive two-column grid in Bootstrap 4.4 is a straightforward process that

Currently using Bootstrap 4.4.1. Experimented with a 2-column layout: Image on the left and Text on the right. <section class="resume-section-first p-3 p-lg-5 d-flex align-items-center" id="about"> <div class="w-100"> < ...

What is the procedure for adding a NULL value to an INT field in a database?

Instead of utilizing an HTML form to gather values for this query, I am executing a second query after the user generates a specific record. The issue arises when attempting to insert '0' into the database unless the data type is changed to VARCH ...

What is causing align-items-center to not function properly in Bootstrap4?

Exploring the inner workings of a solved question Personal experience with the functioning process Currently utilizing Bootstrap4 and attempting to vertically center the main container. Unfortunately, encountering issues with this task :/ Screenshot of ...

Interacting with an iframe element using Selenium in Python

I have a webpage with an iframe embedded, and I'm using Selenium for test automation: <iframe class="wysihtml5-sandbox" security="restricted" allowtransparency="true" frameborder="0" width="0" height="0" marginwidth="0" marginheight="0" style="dis ...

Transitioning the Background Image is a common design technique

After spending hours trying to figure out how to make my background "jumbotron" change images smoothly with a transition, I am still stuck. I have tried both internal scripts and JavaScript, but nothing seems to work. Is there any way to achieve this witho ...

Using JavaScript, you can manipulate the position of a line on a canvas to

I want to create a feature where users can manipulate lines on a canvas by skewing them. This means they would be able to drag one end point of the line to a desired point on the same x-axis using JavaScript and HTML5 canvas. Can someone please provide g ...

Styling: Ensuring my sidebar does not overlap with my main content on the webpage

Currently, I am working on arranging my sidebar and map so that they are displayed side by side instead of the sidebar appearing on top of the map (as shown in the image). I'm seeking advice on how to achieve this layout using CSS because I have been ...

What is the best way to convert line breaks within a textarea to use <br/> instead?

In my project, I have created a textarea along with a button. This button is designed to replace line breaks within the textarea with <br /> tags. Sample Code: var gtcontbtnafterTA = document.getElementById("contbtnafterTA"); var gtRequesttextare ...

In Chrome, a child element with a fixed position inside a parent element with a relative position may appear disconnected from the

If I have an element on my website with a relative position, and within that element I want another element with a fixed position. The Issue: In various browsers (FF, IE, Opera) and in earlier versions of Chrome (tested on Chrome version 26.0.1410), the ...

Adding an iframe with inline script to my Next.js website: A step-by-step guide

For my Next.js project, I have this iframe that needs to be integrated: <iframe class="plot" aria-label="Map" id="datawrapper-chart-${id}" src="https://datawrapper.dwcdn.net/${id}/1/" style="width: ...

Images in the center with a div overlay on top

I'm attempting to place a div or span on top of an image that is positioned above another image. Both images are centered and resized to fit. The height of my images is greater than the width, but they are not set at a fixed size. I want the div to pe ...