Is your mobile responsive dropdown causing issues with content placement?

After implementing a bootstrap header that collapses into a dropdown menu, I noticed that the content below it was being pushed down when the image moved properly but the text on the image did not. Even though the image moves correctly when the dropdown is activated, the text remains static and does not shift downward as well.

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

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

I need to either overlay the text or ensure that it moves down along with the image when the dropdown menu is triggered.

Below is my HTML code:

<nav class="navbar navbar-inverse">
  <div class="container-fluid" id="container">
    <div class="navbar-header" >
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
        <span class="icon-bar" style="background: black !important;"></span>
        <span class="icon-bar" style="background: black !important;"></span>
        <span class="icon-bar" style="background: black !important;"></span>                        
      </button>
      <img src="./assets/logo.png" class="logo" >
    </div>
    <div class="collapse navbar-collapse" id="myNavbar">
      <ul class="nav navbar-nav">
        <li><a href="#" class="head-link">About</a></li>        
        <li class="dropdown">
          <a class="dropdown-toggle head-link" data-toggle="dropdown"  href="#">Academic <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a class="head-link" href="#">Page 1-1</a></li>
            <li><a class="head-link" href="#">Page 1-2</a></li>
            <li><a class="head-link" href="#">Page 1-3</a></li>
          </ul>
        </li>
        <li><a class="head-link" href="#">Locations</a></li>
        <li><a class="head-link" href="#">Solutions</a></li>
        <li><a class="head-link" href="#">Resources</a></li>
        <button class="sigin-btn">Signup</button>
      </ul>      
    </div>
  </div>
</nav>

<div class="container">
    <img src="./assets/Banner.jpg"  class="banner">
    <span class="cont-line1">Out of focus-</span>
    <span class="cont-line2">Achieve with us</span>
</div>

Answer №1

Here is some custom CSS code you can use for your .dropdown-item styling. Feel free to adjust it as needed:

.dropdown-item {
    display: block;
    max-width: 100%;
    padding:0;
    clear: both;
    font-weight: 400;
    color: #212529;
    text-align: inherit;
    white-space: nowrap;
    background-color: transparent;
    border: 0;
}

Additionally, include the following CSS in your stylesheet:

.navbar-collapse {
    max-height: calc(100vh - 60px);
    overflow-y: auto;
}

By adding these styles, your dropdown items and navbar should look great. Hope this solution works well for you!

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

Tips for creating pill progress bars that overlap each other

I am attempting to design a progress bar in bootstrap that displays projected and actual results, with a unique rounded "pill" shape on the right side. Below is the code snippet showcasing my progress: const data = { actual: 1155, projected: 1 ...

Is there a way to customize the appearance of the current slide in slick.js with jQuery?

I am looking to customize the appearance of the currently active slide by giving it an orange border. Keep in mind that the class for the active slide is : slick-active and the structure is as follows : <div class='slick-slide slick-active' ...

Having a CSS position fixed within a div container with the same width as its parent container

At the moment, I have three sections: left, center, and right. I want to add a fixed position div (notification) inside the center section so that it remains in place when scrolling. Additionally, I want this notification to resize according to changes in ...

What is the most efficient way to create a vertically stacked grid with minimal reliance on JavaScript?

When using an AngularJS ng-repeat, I encounter an issue with aligning elements on a new line. Instead of aligning the element above it, all elements on the same 'row' align with the lowest-hanging element. Even though I am using Bootstrap, I cou ...

How to handle users with disabled Javascript? Considering redirection to alternate sites for users with script disabled?

I've dedicated today to strategizing the best approach for revamping our company's website, taking into consideration that less than 1% of web users have JavaScript disabled. Our management team strongly believes in ensuring that our website rem ...

Preventing HTML form submission after displaying an alert in Vanilla JavaScript

I have created a quiz using HTML with validation. The next step is to score the quiz in JavaScript. The scoring system works fine, but I want to prevent the form from posting to result.html if the user scores 0 on the quiz. I've managed to display an ...

The function driver.find_element is unable to locate an element using the "class_name" attribute

My attempt at using driver.find_element, with the "class_name" method to locate and click on a button for expanding rooms on this website resulted in an error message: raise exception_class(message, screen, stacktrace) selenium.common.exceptions.N ...

Is there a way to alter multiple classes using hover effect on a single class without the use of JavaScript, only employing

Hello there! I have a question about applying styles to specific classes when hovering over certain elements. Unfortunately, I am unable to make changes to the HTML files and can only work with the CSS file. Take a look at the image below for reference: ht ...

Is there a way to align the content in my Flexbox rows to the top of each cell, resembling a table layout?

I am currently facing challenges in aligning my layout correctly, especially on resolving the final adjustments. In the scenario described below, everything seems to work fine when the message_data <span> elements contain a single line of data. Howe ...

Step-by-step guide on inserting an image directly into an HTML file without utilizing LinkedResource or CDO

Let's say we have a scenario: My objective is to put together an HTML file with an embedded image, similar to the structure below: <html> <head> </head> <body> <img src="?" /> </body> </html> The quest ...

the function does not wait for the DOM content to finish loading

As I execute the code, an error occurs stating that setting innerText of Null is not allowed. I understand that this is because my function runs before the DOM is completely loaded, but I am unsure of how to resolve this issue. Attempts have been made usi ...

Guide to activating the submit button when a radio button is selected

Here is the code snippet for an edit form <form [formGroup]="editForm" (ngSubmit)="saveUser()" novalidate> <div class="form-group"> <label class="block">Gender</label> <div class="clip-radio radio-primary"> &l ...

Analyzing JSON information and presenting findings within a table

Requesting user input to generate a JSON object based on their response. Interested in showcasing specific details from the object in a table format for user viewing. Questioning the efficiency and clarity of current approach. My current progress: In HTM ...

Skipping is a common issue encountered when utilizing Bootstrap's Affix feature

I'm trying to implement Bootstraps Affix feature in a sticky subnav. <div class="container" data-spy="affix" data-offset-top="417" id="subnav"> I've adjusted the offset to ensure there's no "skip" or "jump" when the subnav sticks. Ho ...

Modify the position of the CSS background for the Y-axis using jQuery

Let's consider a scenario with the following table: <table> <tr> <td class="t"></td> <td class="e"></td> <td class="s"></td> <td class="t"></td> </ ...

Having trouble retrieving data from a contact form with php, js, and ajax?

I am facing an issue with my contact form on a website. I am unable to receive the filled fields from the contact form via email. Can someone please help me figure out what is wrong with the code or suggest an alternative solution? Any assistance in fixing ...

"Verifying the dimensions of the input sizes with the i

It's possible that this question has been asked before on this platform. However, I haven't come across a satisfactory answer yet. How can I adjust the size of inputs in the iCheck library? The current size is too large for my website. Css: .ic ...

Strange occurrences within the realm of javascript animations

The slider works smoothly up until slide 20 and then it suddenly starts cycling through all the slides again before landing on the correct one. Any insights into why this is happening would be greatly appreciated. This issue is occurring with the wp-coda- ...

Is there a way to connect an HTML page without using a hyperlink?

Is there a way to directly display linked HTML pages on my webpage instead of just creating a link? I'm looking for suggestions on how to arrange this. Thank you! ...

What is the reason for the .onclick function impacting all anchor links that share the same URL?

Whenever I click on a hyperlink with the id 1232c or 1233b in test.html, only the first alert (1232c) from the JavaScript code in test.js pops up. This is odd because I have specified different onclick functions for each anchor element based on their ids. ...