In bootstrap, two overlapping DIVs are displayed below each other in mobile mode

I have a setup with two divs.

The initial div consists of a header bar containing navigation links and a logo. Directly below is the second div, which features a hero image accompanied by some text.

These divs are nested within a header tag, with the first div overlapping the second.

My goal is for this overlapping to be maintained in desktop view, but for the second div to shift below the first on mobile devices like iPhones or Galaxies.

To achieve this, I am looking for a solution using Bootstrap. Bootstrap

Importantly, I do not want the divs to appear side by side under any circumstances.

  <div class="page-header-bar is-fixed ">

<div class="header-bar header-bar-primary " id="header-bar">
  <div class="container header-bar-container" id="headerBar">

    <nav class="navbar navbar-expand-lg navbar-light">
      <button class="navbar-toggler"type="button">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbar-main">
        <ul class="navbar-nav">
          <li class="nav-item">Link 1
          </li>
          <li class="nav-item">Link 2
          </li>
          <li class="nav-item">
            Link 3
          </li>
          <li class="nav-item">Link 4
          </li>
        </ul>
      </div>
    </nav>
  </div>

</div>

and here's the code for the second div:

<div class="section">
<div class="hero ">
  <div class="hero-image-wrapper ">
    <picture>
      <img src="/aPicture.jpg" alt="Teaser" width="100%" height="100%">
    </picture>
  </div>

</div>

Answer №1

Instead of using a generic <div> with the class "section", opt for a proper HTML <section> element.

You can set your image as the background of the <section> by styling it with CSS to ensure it remains full width.

Feel free to organize your content however you like within the <section>.

Your image will always serve as the backdrop.

HTML

<section id="hero">
    <div class="row">
       <div class="col">
           <!-- Your hero text goes here -->
       </div>
    </div>
</section>

CSS

#hero{
 background: url(/aPicture.jpg) 50% 50% no-repeat;
 background-size: cover;
}

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

The horizontal display of JqueryMobile radiobuttons is not appearing correctly

My aim is to dynamically generate a set of radio buttons using JQueryMobile. Everything seems to be working fine except for the data-type='horizontal' attribute: On looking at this fiddle, you'll notice that the "created-via-js" radio group ...

One-of-a-kind Design: Linear Gradient Background Image

Can you help me with Linear Gradient? Is it feasible to incorporate an actual image instead of just displaying a color like #000000 or #ffffff? background-image: -webkit-linear-gradient(30deg, #000000 50%, #ffffff 50%); In the scenario mentioned above ( ...

Position the background in CSS according to the class name

There are a total of 8 icons, with 4 in blue and 4 in grey. Therefore, product 1 has both a blue icon and a grey icon. When the user has product 1, they will see the blue icon (with an added class on the container called .gotProduct), and when they don&ap ...

Positioning and resizing elements based on varying screen sizes and levels of zoom

I recently designed a basic webpage using HTML with two main elements - a chat window for user interaction and a chart.js plot. Here is a snippet of the HTML code: <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...

Choose class based on the retrieved information

Good morning, I am working on dynamically setting the class of a td element based on data fetched from a database to reflect any changes or updates. One of the fields returned has four possible options, and I need to modify the CSS class of that field acc ...

I am looking to display the pop-up exclusively when the page is clicked, but unfortunately it is also appearing when the Menu is clicked

I've been working on this code and trying to make some modifications, but I just can't seem to find the right solution for my issue <!-- Updated main content --> <main> <p> Click on the menu button located in the top right ...

The Android Webview is experiencing difficulties with loading CSS styles and displaying the blockquote font color effect

I am facing an issue with loading HTML content in CSS through Android WebView. Despite having the code executed, I don't see any observable changes in font color for the text inside blockquote tags Here is the HTML code: <html> <head> ...

Are you able to parse HTML using qt?

Is there a simple method to retrieve specific content from an html page, like extracting all strong tags that are within p tags with the class name A? The equivalent xpath would be .//p[@class='A']/strong. ...

Steps to include a HTML webpage within another page

I need assistance with a scenario involving two separate HTML pages on different servers. Merchant Form - Server A Payment Form - Server B Here's the desired scenario: The user completes all necessary fields on the Merchant Form and clicks submit. ...

Designing the Mailchimp signup form with React styling techniques

I downloaded the NPM React module for Mailchimp from this link: https://www.npmjs.com/package/react-mailchimp-form. It works well and provides all the necessary forms, but I'm having trouble customizing its style. The documentation suggests adding a ...

Issue with forms not correctly transferring data from selected checkboxes

I am attempting to submit all checked input checkboxes. The input fields are dynamically generated through a Django loop. Based on my research, the code below should be functional. I suspect that the issue lies in the generation of input fields within the ...

Utilizing jQuery to dynamically add classes

I am looking to dynamically add a date picker to input fields using jquery. It seems to be working fine for the first text field, but as soon as I add additional fields, it stops working. Any suggestions on how I can fix this? Thank you in advance. <ta ...

Swapping out a button

I tried searching for a solution to my problem but I couldn't find it because of my limited English proficiency. Therefore, I apologize if my question has already been answered. https://i.sstatic.net/XhQBM.jpg I would like to place my button in the ...

What is the process for creating a personalized user input in JavaScript?

When entering a tracking number, please ensure it follows this specific format: AB-CDEFG-H. The first character (A) must be a digit between 1 and 9 inclusive. The second character (B) should be an uppercase English letter. This is followed by a hyphen (-). ...

"The application is experiencing issues with loading styles correctly when using jQuery append (Fiddler has been

When attempting to load a div tag using the .append() method, the styles are not loading correctly. Here's the code that was tested: <section id="year-2020" class="tab-panel"> <div class="row accordion"> <header> ...

Tips for successfully passing ExpressJS locals variable to an EJS template and utilizing it as a parameter when invoking a JavaScript function during the onload HTML event

const hostname = "192.168.8.154"; const port = 3002; app.use('*', function (req, res, next) { db.collection('sys_params').find().toArray() .then(sysParams => { //console.log(sysParams); app.locals.sysParams ...

Copy and paste the code from your clipboard into various input fields

I have been searching for a Vanilla JavaScript solution to copy and paste code into multiple input fields. Although I have found solutions on the internet, they are all jQuery-based. Here is an example of such a jQuery solution <input type="text" maxl ...

jQuery - class remains unchanged on second click event

Operations: Upon clicking on an element with the class thumb_like or thumb_unlike, a like will be added or removed for the image using a POST request. The element with the class thumb_count will increase or decrease based on user actions. For example, lik ...

How can I alter the color of the menu text when scrolling to the top of a webpage?

As I navigate my website, I encounter a menu with a transparent background at the top that changes to black as I scroll down. On a specific page where the background is white, this presents an issue: when the menu reaches the top, the white background clas ...

Show a component when there is no input value, then conceal it when an input value is present

Recently, I attempted to position a paragraph absolutely in relation to an input element. My goal is to conceal the paragraph when the input has a value, and reveal it when the input is empty. Here is the code snippet I created, however, it doesn't ...