The navbar expands in height when resized

I've been working on creating a responsive navbar, but I'm facing an issue where the height of the bar doubles between phone screen size and full window size. Despite trying various Bootstrap classes, I haven't had any success in fixing this problem. The navigation bar appears correctly in full-screen format:

https://i.sstatic.net/U0NEN.png

However, when I reduce the browser window size, the navbar's height increases (see image below) which is incorrect:

https://i.sstatic.net/zhejS.png

If anyone could provide insights into what might be causing this issue, it would be greatly appreciated.


    <!-- header area start -->
    <header id="header">
    <div class="header-area">
        <div class="container">
            <div class="row d-flex align-items-center justify-content-between">
                <!-- <div class="menu-area"> -->
                    <div class="">
                        <div class="logo px-4">
                            <h3 style="color: #ffffff;"><a style="color: #ffffff;">Header</a></h3>
                        </div>
                    </div>
                    <div class="col-lg-9 d-none d-md-block">
                        <div class="main-menu">
...
                        </div>
                    </div>
                    <div class="col-md-12 col-12 d-none d-sm-block d-md-none d-block d-sm-none">
                        <div class="mobile_menu"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
  </header>
  <!-- header area end -->
.header-area{position:fixed;left:0;top:0;width:100%;z-index:998;background-color:#27ae60}
.menu-area{display:flex;align-items:center}
.logo h3{font-family:'Lato',sans-serif;color:#fff}
.logo a{display:inline-block;font-family:'Lato',sans-serif;color:#fff;font-size:18px}

Answer №1

As far as I understand, each direct child of the row element should ideally be a col in order to ensure that all children add up to 12 and adjust the width accordingly. So, when specifying col-lg-9, it means that in a large viewport, this division should take up 9/12 of the width. In smaller viewports, it will occupy the full 12 width and stack vertically. Here's an example:

For large screens:

| col-lg-2 |          col-lg-6          |    col-lg-4    |

For medium and small screens:


 |     col-lg-2     |
 |     col-lg-6     |
 |     col-lg-4     |

You have the flexibility to fine-tune this layout using md and sm classes to customize how they behave at those specific viewports. Keeping all your classes totaling 12 and using consistent sizing like lg, md, or sm across them is recommended.

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

Is there a way to transfer the data from a `HtmlService.createHtmlOutput()` to a variable after clicking the `submit` button event?

The code snippet below is encountering an issue where arrayStored is not defined in the submit function. I attempted to retrieve the value of arrayStored using the e.parameter method, but it did not work as expected. As a newcomer to HtmlService, I am cu ...

What is the process to include a CSS file in PHP?

Can anyone guide me on how to include my CSS file in PHP? require('config.php'); $cssFile = "style.css"; echo "<link rel='stylesheet' href='/books/style.css'>"; What is the process of adding CSS to a PHP appl ...

Uploading an image without the submit event is not possible with AJAX

Looking for a way to upload images asynchronously using AJAX? I've scoured the internet for solutions, tried various combinations of codes, but none seem to work without a submit event. I want to stress that I can upload images using a button that tri ...

Leverage the input value from a text field within the same HTML document

Is it possible to utilize the input text value assigned to name='t0' within the same HTML document? Here's the code snippet you can refer to - <!DOCTYPE html> <head> <link rel="stylesheet" href="https://sta ...

The button click event fails to trigger after entering text into an input field

I created a basic calculator. Users can input a value in the designated field and then click on the '+' button. The cursor stays in the input field, allowing users to immediately enter a new value after clicking the '+'. The mouse poi ...

To showcase the entire contents of a specific column from one table onto a different table on the following page once the box is ticked

Everything seems to be running smoothly, except for one issue. When a row contains the value "hello world" in a column on the first page, it only displays "hello" in the item column on the second page. I'd like it to show the full value "hello world" ...

What is the best way to dynamically insert a new row into a table, with each row containing a table heading and column?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table id="tbl" class="tbl1"> <tr> <th> mobileno </th> <td class='mo' id="mo_0"> </td> ...

Locating the CSS pixel value without being affected by the browser's zoom settings

Check out this JS fiddle I created to illustrate my issue. As you zoom in and out of the browser page, the value of max-width that appears in the console keeps changing. However, in the CSS code it is always set to 500px. How can I retrieve the original CS ...

Attempting to toggle the visibility of div elements based on radio button selections

I'm currently working on a script that will dynamically show and hide different div elements based on the radio button selection made by users. The jQuery library is loading correctly, as I have tested it with an alert message upon page load. Si ...

"Learn the step-by-step process of generating a transcript with a WebVTT file in JWPlayer

We have integrated JWPlayer into our website and are now looking to add transcript captioning. I have attempted to create a sample application using regular HTML code, but have not been successful. Despite reviewing multiple tutorials, I was unable to ach ...

Here is how you can include a date picker with the ability to choose the day, month, and year

Can someone help me create a datepicker with options to select days, months, and years? I've been able to find resources for selecting months and years, but I'm having trouble adding the option to choose specific days. If anyone has experience ...

Creating a two-column post loop in Wordpress is a great way to display content in a

I've been attempting to separate posts for a long time without success. No matter what variations I try, the result is always either a single post or duplicating all of them. In other words, multiple posts are not displaying as intended. If anyone ha ...

How to vertically align Bootstrap5 buttons on mobile devices

I'm currently developing a web application and I'm facing an issue with centering two bootstrap buttons next to each other on mobile devices. While it works fine on the computer, when I inspect the page on a mobile device, the buttons stack verti ...

Having trouble adjusting the vertical position of jQuery Spinner buttons

I'm attempting to customize the jQuery spinner with styling applied like this: <span class="ui-spinner ui-widget ui-widget-content ui-corner-all" style="height: 14px;"> <input id="testSpinner" class="ui-spinner-input" name="value" aria-value ...

Using `href="#"` may not function as expected when it is generated by a PHP AJAX function

I am facing an issue with loading html content into a div after the page has loaded using an ajax call. The setup involves a php function fetching data from the database and echoing it as html code to be placed inside the specified div. Here is my current ...

Can the site be shown in the background?

I have a unique idea for a games website that I want to share. It's a bit difficult to explain, so please bear with me as I try to convey my vision! The inspiration for this project comes from a website called . Have you seen it before? The concept i ...

Tips for validating user input in AngularJS without using a form tag

Within a popup, I am displaying HTML content that has been copied from another div and shown in the popup. I need to validate this input field to ensure it is required, and display an error message below the input box. <!-- HTML code for changing zip c ...

Changes in browser size will not affect the height

Is there a way to smoothly change the height of the navigation bar when resizing the browser? Currently, it snaps to the new height when the width goes below or above 1000px. Any suggestions? nav.cust-navbar { -webkit-transition: height 2s; tran ...

Scrollable container with jQuery draggable functionality

I am currently working on implementing a draggable list that I want to contain within a scrollable div. $( ".draggable" ).draggable(); Here is the fiddle I have created for this: http://jsfiddle.net/YvJhE/660/ However, the issue I am facing is that the ...

Text aligned at the center of the Y and X axis

I am looking to center my content along the Y axis instead of only on the X axis. To prevent the page from expanding beyond its current size, I have applied the following CSS: html { overflow-y: hidden; overflow-x: hidden } What I want to achieve is havi ...