Step-by-step guide on creating a unique Bootstrap Nav overlay effect

My Bootstrap navigation bar is functioning properly

However, I am facing an issue in adding an overlay to the NAV menu on mobile screens

I am using Bootstrap and Umbraco 7

<nav class="navbar navbar-fixed-top navbar-default" role="navigation">

    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">

            @foreach (var item in selection)
            {
                <span class="icon-bar" style="background-color: @item.GetPropertyValue("navLinkColor")"></span>
            }

        </button>

        @Html.Partial("Shared/Logo")

    </div>

    <div class="navbar-collapse collapse">

        @Html.Partial("Shared/MainNav")

        @Html.Partial("Shared/Links")

    </div>
</nav>

The code above works perfectly on full Desktop screens - But how can I achieve a collapse overlay effect similar to the image attached?

https://i.sstatic.net/GNNY5.jpg.

Answer №1

To create a responsive design, it is recommended to utilize @media queries specifying the maximum width for mobile menu display and minimum width for desktop view.

Find more information about Bootstrap responsive breakpoints here.

 // Targeting different screen sizes using media queries
    // Extra small devices (portrait phones, less than 576px)
    // 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) { ... }

An alternative approach would be utilizing Sass:

@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 application:
@include media-breakpoint-up(sm) {
  .some-class {
    display: block;
  }
}

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

Having trouble retrieving JSON data from an Ajax POST request in PHP

I am facing an issue when trying to retrieve object values from JSON in a POST request sent to my PHP script. The structure of the POST data is as shown below: [{"name":"amount","value":"12"}] Javascript ("#idForm").submit(function(e) { var url ...

PL/SQL Process in Oracle APEX fails to respond when triggered via AJAX before the page unloads

In my Oracle APEX 4.2 environment, I created a PLSQL process set to execute "On Demand - When this process is called by AJAX." The purpose of this process is to update two member attributes in a collection that I established when the page loaded. Here is t ...

"Dealing with Angular .map() function returning an empty array or displaying error messages

I'm encountering two issues while attempting to display data from my API call using the following code... API Call: getProducts(id: number) { return from(Preferences.get({ key: 'TOKEN_KEY' })).pipe( switchMap(token => { ...

Turning the Three.js camera to the left and right side

My goal in Three.js is to create an orbiting camera that can be rotated around the x and y axes. I have implemented two functions to achieve this: function rotateX(rot) { var x = camera.position.x, y = camera.position.y, ...

What is the best way to achieve a stylish Bootstrap modal design with a blurred and transparent header, as well as a left sidebar that seamlessly blends into

Is it feasible to create a modal with a blurred (transparent) background for the header section, allowing the site to show through? Additionally, can a sidebar on the left side of the modal also be transparent and blurred, revealing the site underneath? C ...

Why is the lower right white space left unfilled by the color red?

I'm having issues with using named lines in grid for layout. The red section is not positioning correctly next to the footer, and I can't figure out where I went wrong. * { box-sizing: border-box; margin: 0; padding: 0; } .container { ...

Is it possible to bind HTML within an AngularJS partial but encountering an inexplicable issue?

I'm facing an issue with my ng-repeat that involves using a partial HTML file to loop through and display items on a page. The variables within the partial are not displaying, but interestingly enough, the variable {{rule.name}} outside of the partial ...

Displaying Mustache.js in an HTML template

I attempted to integrate mustache.js into my web application. After loading the mustache.js file, I included the following script in my code: <script type="text/javascript> $(document).ready(function () { var person = { first ...

Is it possible for PHP to dynamically load a file based on a condition set in JavaScript?

I am attempting to dynamically insert a PHP include onto the page once the user scrolls to a specific part of the page. Is this feasible? For example: var hasReachedPoint = false; $(window).scroll(function() { var $this = $(this); if ($this.scrollTo ...

Pressing the enter key in the input field will cause the multistep progress bar to update its

When I press Enter in each input field, I want the multi-step progress bar to dynamically update by adding the 'is-active' class to the next list item and removing it from the previous one. How can I achieve this using jQuery? ...

Technique for updating URL when submitting a form on a webpage

I'm a newcomer to the world of coding and I have a simple issue that needs fixing. I want to create a form field where users can input the last segment of a URL provided to them. After entering this segment, I want the page to refresh automatically a ...

The performance of aframe is being affected by the use of bounding boxes for collision

Hey there! I recently created a component to handle collision detection for primitive and non-primitive shapes. While using the bounding box collision feature provided in three.js, everything was working smoothly. However, when applying it to custom object ...

After submitting the comment, you will be redirected to a different page

I am currently working on implementing a comment section for my website. I have created the comment box and successfully set up posting comments and updating them in the database. However, I am facing an issue where upon submitting a comment, the page auto ...

Asynchronous callback in mongoose with an undefined value

I am utilizing 'mongoose' and 'async'. While my search functionality is operational, I encounter an issue where my data does not get passed in the final callback. The variable always ends up being undefined. Despite referencing the mong ...

Incorporate additional information into the current data series within Lightning Chart

In my React JS application, I have successfully used a point series to create a chart displaying data. However, I am now looking to bind real-time data to the chart. For example, when the chart initially loads with 10 points, I want to continuously receiv ...

Neglecting an error from a completed function in Node JS

I am currently facing a challenge in deleting votes from my Firebase database table. It appears to be an asynchronous request that requires some time to process. However, my function concludes prematurely leading to the following error message - Ignoring ...

Using angular.copy function to copy an array with a custom property

Let's use the example below to illustrate an issue: var ar = [4, 2, 3]; ar.$x = 'something'; var br = angular.copy(ar); console.dir(br); After copying ar to br, the $x property is no longer present. This is because when Angular copies an a ...

Is it possible to retain the placeholder text if the user selects the input field and the value is left empty?

Is there a way to make the placeholder text disappear only when the user starts typing at least one character in the input field? Currently, the placeholder disappears as soon as the user focuses on the input. Any suggestions would be appreciated. Thank ...

Upon the completion of the Vue component, all subsequent elements are automatically removed

If you take a look at this website along with its source code, you'll notice an issue. Removing the cdn for the vue-tag-input component causes everything to render except the component itself. However, adding the cdn back results in nothing being disp ...

Introducing the new "Expand/Collapse" feature - enhancing the way content placement functions!

I have added a 'view all' button to toggle the visibility of a section on my website. Currently, clicking on the button reveals a long list above it, which is causing confusion for users as the button remains in the same position when clicked. T ...