Adapt your design to different screen sizes with Bootstrap 4

There will be a significant amount of typing required for this task.

I have a page that needs some design adjustments when the screen size is reduced. This includes elements of menus switching positions and additional design features on certain fields.

Currently, I am following Bootstrap 4 documentation closely on responsive breakpoints (https://getbootstrap.com/docs/4.0/layout/overview/)

Providing an example of one of the menus:

<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Navigation Menu</title>
    
    <script src="Libs/JQuery/jquery-3.3.1.slim.min.js"></script>
    <script>window.jQuery || document.write('<script src="Libs/JQuery/jquery-3.3.1.slim.min.js"><\/script>')</script>
    <script src="Libs/Popper/popper.min.js"></script>
    <script src="Libs/Bootstrap/js/bootstrap.bundle.js"></script>
    
    <link rel="stylesheet" type="text/css" href="Libs/Bootstrap/css/bootstrap.css" media="all">
    <link rel="stylesheet" type="text/css" href="Css/TopMenu.css" media="all">
    
</head>
    
<body>

<nav class="navbar navbar-expand-lg navbar-light bg-light" id="top-menu">

    <a class="navbar-brand" href="#"><img src="Images/logo.png" alt="Logo">
        <!-- Carousel -->
    </a>

    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#main-navbar" aria-controls="main-navbar" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse main-navbar" id="main-navbar">

        <ul class="nav navbar-nav mr-auto navbar-one" id="navbar-one">
            <li class="nav-item">
                <a class="nav-link" href="#">PRODUCTS</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">SERVICES</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">COMPANY</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">NEWSROOM-STORY</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">SPOTLIGHT:TECH
                    <?php //echo $spotlight; ?>
                </a>
            </li>
        </ul>
        
        <ul class="nav navbar-nav smaller_font mr-auto navbar-two" id="navbar-two">
            <li class="nav-item">
                <a class="nav-link text-danger" href="#">CUSTOMER DASHBOARD</a>
            </li>
            <li class="nav-itemv">
                <a class="nav-link text-danger" href="#">SHOP</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">PRIVACY POLICY</a>
            </li>
            <li class="nav-itemv">
                <a class="nav-link" href="#">CONTACT</a>
            </li>
        </ul>
        
        <!-- Language Menu -->
        <ul class="nav navbar-nav mr-auto language-menu" id="language-menu">
            <li class="nav-item">
                <a class="nav-link" href="#">DE</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">EN</a>
            </li>
        </ul>

    </div>

</nav>
    
</body>
</html>

The additional CSS code is as follows:

.smaller_font{
    font-size: 80%;
}

@include media-breakpoint-down(md){
    .main-navbar{
        border-bottom: solid 1px;
    }
}

Currently, I am attempting to use @include media-breakpoint-down(md){...} However, the design does not respond at all when the screen size is decreased.

The goal is to add a 1px bottom border to the fields in the menu.

I am aware that there is an option to hide elements and then make them visible as discussed here

or by setting pixel width using the "@media" tag, but using the "@include media-breakpoint-down()" tag seems more logical overall (just my intuition).

I need to find a way to make things work on a small scale so I can build from there :-)

Answer №1

"I'm currently experimenting with the @include media-breakpoint-down(md){...} code snippet, but I'm not seeing any changes in my design when I reduce the size."

Just a reminder, this isn't vanilla CSS...

@include media-breakpoint-down(md){
    .main-navbar{
        border-bottom: solid 1px;
    }
}

It's actually SASS. SASS needs to be compiled into CSS on the server-side before the browser can understand and render the styles.

Answer №2

Discovering valuable information led me to choose an unconventional yet effective solution - incorporating an invisible object into the code. You can find more details here.

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

Access information from multiple div elements using JavaScript data-attributes

Having trouble retrieving data-attribute values from multiple divs with the same class when clicked. The goal is to display the data value of the clicked div. function playSound(e) { const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`) ...

Struggling with the functionality of the navigation bar

Currently, I am facing a challenge with implementing a dropdown menu in my Bootstrap navbar. I am testing it out on JSFiddle to troubleshoot the issue. Here is the correct link: https://jsfiddle.net/addlemanrachel/n9m8fjm8/. Below is the HTML code I am wo ...

Moving the mouse over a div will alter the heading of another div

Trying to find a solution for a unique problem. I have 5 boxes and need to style one box with a different heading color. As I hover over the other 4 boxes, I want the active box heading to change to a new color. The color should remain even after moving th ...

Initiating the click event on a designated element

I'm working on a grid of team members represented by figures with figcaptions. I want to be able to trigger a click function only for the specific figure that has been clicked, rather than applying the function to all figures at once. Here is an exam ...

Guide on creating my inaugural HTML embeddable widget?

A client recently requested me to create a JavaScript (MooTools)/HTML/CSS/PHP based game as a deployable widget. This will be my first time developing a widget, so I am seeking advice and insights to help me navigate any potential challenges from experie ...

Navigate to the left smoothly while maintaining an inline display and automatically adjusting height, with rows functioning correctly but columns

My layout consists of a grid with 8 boxes containing images. Each row has 4 columns, and there are 2 rows in total. The boxes are set to float: left and display: inline. Everything aligns perfectly when the height is fixed. Here is an example: Example Ima ...

What is the best way to switch back and forth between two div elements?

I've been attempting to switch between displaying div .cam1 and div .cam2, however, I can't seem to get it to work. Here's the code snippet in question: HTML: <div class="cam1"></div> <div class="cam2"></div> CS ...

How to display a Bootstrap modal when clicking on buttons within a dynamic loop of <li> tags?

I would like to share a problem I am facing with buttons in 'li' tag loop. When the info button is clicked, a particular modal should open. However, after clicking the button, the modal does not pop up on screen even though the EJS loop is functi ...

Place one flex item in the center and align another item to the bottom

I am attempting to center one flex item both vertically and horizontally. At the same time, I want some text to remain fixed at the bottom of the flex container. When I use margin-top:auto on the text, it just moves the inner box to the top. Any suggesti ...

The hover effect for a :before class is not functioning as intended

I have created a dropdown menu with a triangle at the top in this style: When the cursor hovers over only the triangle, it appears like this: However, when the cursor is over the div, the hover effect for both elements is activated as shown here: I am t ...

Tips for submitting AJAX information instead of traditional form data

I am trying to send a simple input field as JSON data to a web server that I have set up. Here is what I have tried so far: <html> <head> <script src="http://code.jquery.com/jquery-1.11.3.js"></script> <script> $(document).r ...

Button form featuring Ajax in PHP

Can someone please help me figure out what I am missing here? This is a simple HTML file with a "Create" and "Destroy" button that are supposed to call an API. The Ajax functionality seems to be working, but the PHP function is not getting executed. test ...

Issue with nested grid layouts within the 960 grid system

I recently started working on a personal hobby website and decided to utilize the 960 css grid system for organizing my HTML elements on the page. After grasping the basic concept, I went ahead and created a preliminary version of the website, which is ho ...

PHP not receiving POST information from $.ajax call

My JavaScript triggers a POST method when the datepicker loses focus, calling the script rent-fetch-pick-up-point.php. However, the PHP script gets stuck at the if-statement because it's not receiving the POST data. The datepicker is associated with a ...

How to use Nokogiri to efficiently extract targeted nodes from HTML

In my Ruby script, I am trying to extract specific values from an HTML document using the Nokogiri gem. The HTML content I'm parsing includes information about a user and their registered device. #!/usr/bin/ruby require 'Nokogiri' doc = No ...

Identifying the HTML Hidden Attribute Using JavaScript Without Dependencies

As someone working in the analytics field, I often rely on CSS selectors to address various issues. Currently, I am faced with a task on a website where I need to determine whether a <p> element is hidden or visible. There are two possible scenarios: ...

Access local files by utilizing iframe

I attempted to load files via an iframe, however, it was unsuccessful. I am attempting to load a file from: C:/Users/Tom/Desktop/Courses/c2.pdf and I tried: <iframe src="file:///C:/Users/Tom/Desktop/Courses/c2.pdf></iframe> Unfortunately, no ...

"Utilizing HTML aids for creating text input fields and adding line breaks

public string BannerText {get;set;} public void SetBanner() { BannerText = "This is line 1. \nThis is line 2." } on my webpage, I am displaying it like this: <div> <h1><%: Model.BannerText %></h1> </div> The issue ...

Currently, I am compiling a list of tasks that need to be completed, but I am encountering a dilemma that is proving difficult to resolve

Recently delved into the world of Javascript and encountered a roadblock that I can't seem to overcome. Here's the snippet of code causing me trouble: add = document.getElementById("add"); add.addEventListener("click", () => { console.log("Ple ...

The symbol in my Google Maps path is off-center and not aligned correctly

Hey everyone, I'm currently working on a project that involves a plane moving along a polyline, but I'm facing an issue where the path symbol is not centered as demonstrated in this image This is what I have: Here, I define the path symbol as t ...