Mobile responsiveness of Bootstrap navbar

Currently, I am in the process of constructing a Bootstrap 4 website using Jekyll. Each page features a jumbotron that serves as a hero header and everything is functioning smoothly.However, when I resize the viewport to a mobile size, the jumbotron ends up positioned below the fixed header rather than having its own separate space underneath. This issue can be seen in the image provided.

Upon removing the fixed attribute from the header, the layout returns to normal functionality. No alterations have been made to the styling at this point, with only default Bootstrap HTML and styles being used.

Is there a way to prevent this behavior while still keeping the header fixed? Below, you will find the HTML for both the body and navigation sections that are utilized in Jekyll to construct the pages.

Your help on this matter would be greatly appreciated!

<header>
<nav class="navbar navbar-expand-lg fixed-top navbar-light bg-light">
  <!--Site logo-->
  <a class="navbar-brand" href="#">Thomas Bishop</a>
    <!--Collapse nav on mobile viewports-->
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
    </button>
      <!--Nav links-->
      <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav ml-auto">
          <!--Home-->
          <li class="nav-item active">
            <a class="nav-link" href="{{ site.baseurl }}/">Home <span class="sr-only">(current)</span></a>
          </li>
          <!--Services-->
          <li class="nav-item">
            <a class="nav-link" href="{{ site.baseurl }}/services">Services</a>
          </li>
          <!--Expertise-->
          <li class="nav-item">
            <a class="nav-link" href="{{ site.baseurl }}/expertise">Expertise</a>
          </li>
          <!--Blog-->
          <li class="nav-item">
            <a class="nav-link" href="{{ site.baseurl }}/blog">Blog</a>
          </li>
          <!--About-->
          <li class="nav-item">
            <a class="nav-link" href="{{ site.baseurl }}/about">About</a>
          </li>
          <!--Contact-->
          <li class="nav-item">
            <a class="nav-link" href="{{ site.baseurl }}/contact">Contact</a>
          </li>
        </ul>
      </div>
</nav>
</header>

---
layout: default
title: Content Usage Policy
permalink: /content-usage-policy
---
<div class="container-fluid">
  <div class="row">
    <div class="col-12">
  <div class="jumbotron jumbotron-fluid bg-light">
    <h1 class="display-4 d-flex justify-content-center">Content Usage Policy</h1>
    <p class="lead d-flex justify-content-center">Optional sub-heading or meta description</p>
  </div>
</div>
</div>



</div>

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

Answer №1

When utilizing the jumbotron class, it automatically adds a padding-top: 4rem for larger devices and padding-top: 2rem for smaller devices. This can cause overlap with your content and header on small devices.

Additionally, the position: fixed property applied to the navigation bar means that other elements on the page do not recognize its existence. As a result, the next div will also start from top: 0. To resolve this issue, follow these steps:

body > .container-fluid {
    padding-top: 40px;
}

Implementing this CSS will create space between the navigation bar and the content. If you prefer avoiding extra space, apply the following rule specifically for small devices:

@media (max-width: 576px) {
    body > .container-fluid {
        padding-top: 20px;
    }
} 

Ensure that this CSS is loaded after the main Bootstrap stylesheet to take effect correctly.

Answer №2

To ensure your jumbotron is properly displayed on mobile devices, adjust the margin-top or padding-top to match the height of your fixed header using a media query specifically for mobile. Check out this CodePen example illustrating how a fixed header works.

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

Error Handling in React with Stripe Payments

I've been attempting to integrate Stripe into my project, but I keep encountering the following error: Error: Cannot read property 'setPublishableKey' of undefined Below is the code snippet I am using: import React from 'react&apos ...

Fuzzy backdrop for a dynamic navigation bar

Is there a way to achieve a blurred background on a bootstrap 4 navbar? I've attempted using the CSS blur filter, but it ends up blurring all the content within the div as well. Some people have resorted to using SVG to blur whatever is behind the di ...

Upgrade the jQuery code from version 1.4.2 min to version 1.10.2 min

Hey there, I'm looking for assistance with updating the code below to use jQuery 1.10.2. The backslashes are present because I am using it with PHP and need to escape special characters. I'm not very familiar with JavaScript and unsure of the ch ...

Retrieving data from a database in PHP and assigning it as the value for an HTML select tag

Seeking assistance on a project to develop a stock management system for an herb factory using PHP with a MySQL database. Currently working on a page that allows the user to edit the value of a bench containing herbs. The bench details have been stored in ...

What is the best way to enable users to edit the placeholder text in an HTML input field?

I'm dealing with a situation where I have the following code snippet: <input placeholder="something"> Typically, the placeholder text disappears as soon as the user starts typing. Is there a way to make it so that the placeholder text becomes ...

Creating a row of aligned vertical sliders using jQuery UI

I'm having trouble aligning multiple vertical UI sliders on the same line. Here's what I'm looking to achieve: 1. Have 4 vertical sliders displayed in a row. 2. Show numerical values as the user moves each slider. The code I'm currentl ...

Issue with ngbCollapse feature when attempting to collapse multiple dynamically generated divs on a single page

When dynamically generating ngbCollapse in a main loop that checks for the presence of the Sun in a JSON object, if the Sun is not there, it provides an option to Add_Sun(). Since it is within a loop, it allows adding a sun to every row. When clicking th ...

Attempting to render an image onto a canvas and apply Caman.js for image editing purposes

Currently, I have a code snippet that allows me to draw an image onto a canvas. Here is the code: var imageLoader = document.getElementById('imageLoader'); imageLoader.addEventListener('change', handleImage, false); var ...

Positioning the label for a Material-UI text field with an icon adornment when the shrink property is set

https://i.stack.imgur.com/E85yj.png Utilizing Material-UI's TextField, I have an Icon embedded within. The issue arises when the label "Your good name here" overlaps the icon instead of being placed beside it. This problem emerged after I included ...

Having trouble with ng-select focus in Angular 5?

I've been attempting to implement focus on ng-select within Angular 5, but unfortunately, it doesn't seem to be working as expected. Currently, I am utilizing ng2-select for my project. Is there a specific method for implementing focus on ng-se ...

The jQuery tooltip fails to function properly after the AJAX content is loaded

I have been using a tooltip script that can be found at: This is the script I am using, with a few modifications: $(document).ready(function() { $("body").on("mouseover", ".tip_trigger", function(){ tip = $(this).find('.tip&apos ...

troubles with downloading using the <a> tag

I attempted to create a personalized file name for user downloads, but I am having trouble using ${} in the process. My goal is: let foo = "name" let fileName = `${name}footer.html` <a download={filename} className="btn btn-info">Download</a> ...

Arrangement of items in a grid featuring a row of three items, each with an automatic width

I'm facing challenges with achieving a specific layout: https://i.sstatic.net/a5ETh.png https://i.sstatic.net/I7fuS.png My goal is to have the left and right elements automatically adjust their width to cover all the empty space on either side of t ...

Is there a way to wrap the "#+ATTR_HTML" tags around the preview output of the "#+RESULTS" Source Block in Org-mode for Emacs?

Using plantuml in org works fine for me. However, I am looking to enhance it by automatically inserting some HTML tags just before the #+RESULTS output tag. This will help achieve a more visually appealing HTML output effect. Here's an example of my ...

What are some strategies for accessing the original values of form components that have not been altered when using ngModel?

I am currently developing a form and I intend to utilize the previous values as "value" in the form. By employing ngModel dynamically, I am able to change some properties. However, I have encountered an issue where the field that remains unchanged by the u ...

Examining pseudo-elements on Internet Explorer

Recently, I encountered an issue with a pseudo-element: input[type=radio].selected::before Surprisingly, in Internet Explorer, the pseudo-element wasn't visible at all. This prompted me to investigate further. Upon inspecting the selector (imagi ...

Moving responsive table cell to a new line

Currently, I am faced with the challenge of embedding third-party content via dynamic means without any knowledge of Ajax or jQuery. My question is whether it's feasible to move a table cell onto a new line, essentially creating a new row. The embedd ...

Unusual behavior in iOS Safari when double-clicking or hovering

After completing a responsive redesign for one of my websites, I noticed an unusual behavior with the links that went unnoticed by testers: When clicking on these links, they are only "activated" but not followed. However, if you click them again, they wo ...

Deactivate Bootstrap Button Pills and Activate Change with an Alternate Button

Seeking a solution for my multi-step form utilizing Bootstrap nav-pills. Currently, users can navigate through the steps without completing the required form fields first. I am looking to disable this feature and trigger content changes with a different bu ...

Button clicking to zoom in and out with three.js

I am looking to include two buttons for zooming in and zooming out. How can I achieve this? I attempted to use the following code, but it did not work for me. var controls = new THREE.OrbitControls(camera, renderer.domElement); function zoomModel(isZoo ...