Displaying the content of a Bootstrap 4 row on top of the navbar

Just starting out with Bootstrap and recreated a page layout similar to the starter template on the Bootstrap website. However, I'm facing an issue where the row content overlaps the navbar, despite using the align-items-center utility class on the row.

Check out this image

HTML

<body class="bg-dark -bg-pic -fill-viewport">

<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-transparent">
    <div class="container">
        <a class="navbar-brand" href="#">####</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarCollapse">
            <ul class="navbar-nav mr-auto">
            <li class="nav-item active">
                <a class="nav-link -link-active px-0 mx-2" href="#">Main Page</a>
            </li>
            <li class="nav-item">
                <a class="nav-link -link px-0 mx-2" href="#">Add Listing</a>
            </li>
            </ul>
            <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Login</button>
        </div>
    </div>
</nav>

<main role="main" class="container">
    <div class="row">
        <div class="col-md-2 col-lg-3"></div>
        <div class="col-12 col-md-8 col-lg-6 text-center">
            <h1 class="text-white">Hello</h1>
            <p class="lead -text-white-70">Lorem ipsum dolor sit amet, consectetur adipiscing elit.
                    Vestibulum sed ipsum ac turpis vestibulum aliquet.
                    Morbi ac neque quis justo posuere tincidunt in id arcus.</p>
            <form class="" action="#">
                <div class="input-group">
                    <input class="form-control" placeholder="Search" name="search" type="text">
                    <div class="input-group-append">
                        <button type="submit" class="btn btn-primary"><i class="fas fa-search"></i></button>
                    </div>
                </div>
            </form>
        </div>
        <div class="col-md-2 col-lg-3"></div>
    </div>
</main>

CUSTOM CSS

/* Utility classes*/
.-fill-viewport {
    min-height: 100vh;
}

.-text-white-70 {
    color: rgba(255,255,255,0.7);
}

/* Medium devices and higher */
@media only screen and (min-width: 768px) {
    .-link-active {
        border-style: solid;
        border-color: white;
        border-width: 0px 0px 3px 0px;        
    }

    .-link:hover {
        border-style: solid;
        border-color: rgba(211,211,211,0.6);
        border-width: 0px 0px 3px 0px;

    }
}

/* small devices and higher */
@media only screen and (min-width: 576px) {
    .-bg-pic {
        background: linear-gradient(
                    rgba(20,20,20, .6), 
                    rgba(20,20,20, .6)),
                    url("background.jpeg") center/cover no-repeat;
    }
}

Answer №1

The reason for this issue is the use of fixed-top in the navbar.

To resolve this, simply add mt-5 to your main container, and also consider adding pt-5 if necessary.

<main role="main" class="container mt-5 pt-5">

The mt-* class refers to "margin-top," while pt-* class refers to "padding-top."

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

Making a Dialog resizable with jQuery's Resizable Helper

Is there a way to implement the Helper feature from jQuery Resizable, which only shows a frame while resizing the container, in a Dialog? ...

Instead of relying on a button click to trigger a script, set up the script to load automatically when inputs are detected

Recently, I created a simple calculator web-app using Angular. In my app.component.html file, I have the following code: <div style="text-align:center"> <h1>Calculator</h1> <input type="text" id="firstNumber" placeholder="Firs ...

Activate a button on-the-fly

When the page loads, I have an empty array. Since there are no values stored in this array, I disabled the button using ng-disabled="array1.length==0". Now, on the page that opens up, there are four drop downs present. My goal is to enable the button once ...

Can CSS be used to create drop down menus?

Is it possible to create a dropdown menu using only CSS, similar to what you would find in most applications? I have a simple menu bar at the top of my screen and I want to be able to hover over an item like "Item1" and see sub-items appear below it. I en ...

Mastering the art of utilizing defer/async attributes in script tags effectively

When I add the "defer" attribute to all external js files, Owl Carousel fails to load and shows an error that "$" is not defined. However, if I remove the defer attribute from the script tag, everything works fine without any errors. Unfortunately, I am un ...

Building a Bootstrap Tooltip

Here is a brief code excerpt: link HTML CODE: <a href="#" data-toggle="tooltip" title="Hooray!">Hover over me</a> asda example link I am puzzled by the discrepancies between my implementation and the one on W3Schools. I have used the sam ...

Troubleshooting problem with scrollbar in HTML table within a div element

I'm utilizing Bootstrap for the majority of my CSS. I've split a section into two columns, with the left column displaying a table with data and the right side featuring a Google map. The issue arises when the table row grows, as it doesn't ...

Z-Index not functioning as expected

I've been trying to position my <h1> header on top of a light div with a background image called light.png. I used Z-index to stack them and added position:relative, but for some reason, the <h1> is not showing above the <div class=ligh ...

Steps for changing the direction of a dropdown menu to the left instead of the right

I'm having a bit of an issue with my inbox setup. I have a dropdown for it, but the dropdown is appearing off to the right and since it's at the end of my top navbar, it's not very visible. Here is the CSS code for the inbox: .notification ...

Google Fonts are displaying in a bold style even when the bold property is not set

I need assistance with an issue involving emails going from Salesforce to Outlook 365. Here is the HTML code snippet: <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css"> <style> body ...

Code snippet in Python using Selenium where Google Maps is not visible in the page source

Currently, I am attempting to extract GPS coordinates data from a property listing: https://www.primelocation.com/new-homes/details/55357965?search_identifier=d10d089a335cc707245fb6c924bafbd2 The specific GPS coordinates can be found on the "Map & Nearby" ...

Is there a way to automatically generate and allocate an identifier to an input field?

I've written the code below, but I'm having trouble figuring out if it's accurate. Specifically, I can't seem to access the text inputs that have been created by their respective id attributes. for (i=0;i<t;i++) { div.innerHTML=div. ...

Stop the div from collapsing when hiding or deleting all child elements to maintain its structure

I have recently developed a Vuetify application that manages card items. To ensure security and accessibility, I have added a feature where the actions/buttons are displayed based on the User's permissions. In case of missing permissions, these button ...

Adding an input field and icon at the center using ::after

Having trouble centering an input field with an icon after it in a div. I can center the input text easily using text-align:center, but struggling to center the icon added using ::before. The search text is centered, but not the icon https://i.sstatic.ne ...

Escape sequences do not seem to be functioning properly when using innerHTML

I am facing an issue where a string containing HTML escape characters (such as < and >) needs to be rendered inside a div using innerHTML. The intention is for the escaped characters to appear as text rather than as actual HTML, but they still render ...

bringing in a js file with an import statement at the beginning

I am looking to import a file that brings in another file for use across multiple pages Here is my folder structure: js modules momentum-scrolling index.js about.js contact.js Contents of momentum-scrolling.js: import LocomotiveScroll from &a ...

Learn how to dynamically insert a source for an IMG element in Laravel using Blade by utilizing a variable returned from a view

I have been working on a website that displays various products and I utilize Blade for creating dynamic product pages. Here is an example of how I do it: Route::get('/products/{product}', function ($product) { return view('products/pr ...

How to lineup social media icons across on a Tumblr blog

I managed to successfully integrate the like and tweet buttons into my blog, but I'm struggling with aligning them horizontally after each post. My goal is to position the tweet button just to the left of the facebook like button for a cleaner layout. ...

How to exclude elements nested inside another element using CSS or XPath techniques

Presented here is a snippet of XML code: <xml> <section> <element>good</element> <section class="ignored"> <element>bad</element> </section> </section> </xml> Identifying a ...

Issue with HTML While Utilizing wp_get_attachment_image

This script : $source = wp_get_attachment_image( get_the_ID(), 'medium' ); $weburl = wp_get_attachment_image_url( get_the_ID(), 'full' ); echo( '<p><a href="%s"><img src="%s"></a></p>', $weburl, ...