As I scroll down, my content hovers over my navbar

My website loads with everything in the right place, but as soon as I start scrolling, the content moves onto the navbar and hides at the top of the screen. I want the navbar to remain at the top of the screen at all times and have the content hidden under it.

Here is my navbar code:

<a class="navbar-brand d-flex align-items-center" href="/">
    <a class="navbar-brand" href="/"><img src="img/full_trimmed_transparent_base (3).png" width="381"height="76" class="d-inline-block mr-1 align-bottom" alt=""></a>
</a>

<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mainmenu" aria-controls="mainmenu" aria-expanded="false" aria-label="...">
    <span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="mainmenu">

    <ul class="navbar-nav ml-auto">

        <li class="nav-item active">
            <a class="nav-link" href="/home"> START </a>
        </li>

        <li class="nav-item">
            <a class="nav-link" href="/about_cattery"> O ... </a>
        </li>

        <li class="nav-item">
            <a class="nav-link" href="#"> ...</a>
        </li>

        <li class="nav-item">
            <a class="nav-link " href="#"> ...</a>
        </li>

        <li class="nav-item">
            <a class="nav-link" href="#"> ... </a>
        </li>

        <li class="nav-item">
            <a class="nav-link" href="#">...</a>
        </li>

        <li class="nav-item">
            <a class="nav-link" href="/kontakt"> ...</a>
        </li>
    </ul>
    <ul class="navbar-nav sm-icons">
        <li class="nav-item"><a class="nav-link" href="https://www.facebook.com/...
            <i class="fab fa-facebook-square icon"></i></a>
        </li>
    </ul>
</div>

Here is my CSS for the navbar:

.navbar {
    position: fixed;
    top: 0;
    background-color: rgba(240,240,240,0.5);
    width: 100%;

}

.nav-item {
    font-size: 100%;
     padding-left:3px;
     padding-right:3px;
}

.icon {
    color: #3b5998;
    font-size: 120%;
}

.icon:hover {
    color: #92a6d3;
}

.scrolled {
    background-color: rgba(240,240,240,0.9) !important ;
}

Content CSS:

body {
    padding-top: 120px;
}

Answer №1

To ensure your navbar appears above other elements on the page, increase its z-index value:

.navbar {
    position: fixed;
    top: 0;
    background-color: rgba(240,240,240,0.5);
    width: 100%;
    z-index: 99999999;
}

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 shifting a stuck div 200px upward once the bottom of the page is reached while scrolling:

I've set up a page layout with two columns, one fixed and the other scrollable. The left column is fixed (containing Google ads) and stays in place as I scroll down the page. The right column displays posts and scrolls along with the rest of the con ...

Ratios for Sizing Bootstrap Columns

The Bootstrap grid system consists of 12 columns in total. I am looking to utilize all 12 columns on the page. However, my goal is to have the first 6 columns on the left side be half the width (50%) of the columns on the right side. This means that the ...

Customize the color of the hamburger icon in Vue Bootstrap

I am struggling to change the color of the Vue Bootstrap Hamburger navbar-toggler-icon to white. Despite trying numerous code combinations, I have not been successful. Each time I load the app, the CSS defaults back to the original bootstrap URL. Do you ha ...

What is the best way to make an HTML element's width automatically adjust based on the margin size?

I'm currently working on creating a rectangular button using HTML and CSS. The challenge I'm facing is ensuring that the width of the button remains consistent regardless of the amount of text it contains. Whether it's just a few words or mu ...

Transforming a Bootstrap 4 HTML project into Angular 9

After stumbling upon a beautiful HTML template that caught my eye, I realized it was built using Bootstrap. Luckily, I came across tutorials on how to convert such templates into Angular 6 projects, making the process seem quite straightforward (like this ...

Tips for incorporating border-radius when converting HTML to PDF with xhtmltopdf

I'm having trouble getting the corners of my table to round properly. When I convert the following HTML to a PDF using the xhtmltopdf PDF generator, the border-radius property doesn't seem to work. Below is the HTML code for the content file name ...

Is it possible for me to overlap a text over hidden text, and if the hidden text becomes visible through JavaScript, my text will shift to the right of the now visible hidden text?

I'm currently working on a website for a company that requires users to complete all the information before proceeding. To achieve this, I created a form with the following code: <form action="Owners Infoback.php" onsubmit="return validateFo ...

Ways to obtain the <a> using the title attribute

Is there a way to remove 3 classes from a specific <a> element that is dynamically generated? The only constant is the title. How can I locate an element based on its title? I've searched online but haven't found exactly what I'm looki ...

The .AppendChild() method does not appear to be working as expected following the completion of

Encountering a peculiar problem here. The scripts run smoothly, but the content doesn't display on screen until I "inspect element" and then close the inspector window or zoom in/out. It's not an issue with the "display" CSS property because even ...

How can objects be positioned or moved in a linear fashion, and how to incorporate free fall when adding additional objects?

I'm interested in creating a system similar to a "vibrating table" with linear displacement. After studying various tutorials, I was able to achieve simulations based on the following examples: Following the tutorial "Authoring a Multibody Simulatio ...

Introducing the innovative Icon Collapsable JQuery - a versatile tool that

I'm looking to set custom icons for the JQuery Collapsable view without having to make changes to the default JQuery CSS and .JS files. You can take a look at my starting point on jsFiddle here: http://jsfiddle.net/jakechasan/M7LLU/ Although I' ...

How to Align Two HTML Forms Using CSS

I've been experimenting with various methods, but I'm still unable to achieve the desired outcome. Currently, my setup looks like this: https://i.sstatic.net/fUXKr.png However, what I really want is something more like this: https://i.sstatic ...

The display/block feature will only function if the div element is contained within a table

I am facing an issue with hiding/showing two div elements alternatively. The code works perfectly when the divs are placed within a table, but fails when they are not in a table due to compatibility issues with Internet Explorer. I prefer not to use a tabl ...

Incorporating Anchors for Seamless Navigation in Menus

My website has various sections on the homepage and I want to add an anchor link to the navigation. This will allow users to scroll down to a specific section, like "About Us," when clicking on the appropriate nav link. I also need the anchor link to work ...

Why is the camera access permission dialog not showing up in the WeChat app?

Why is it that when I attempt to open the following links for the first time, Chrome asks for camera permission, but when I access them through WeChat's in-app browser, the camera permission dialog does not appear? Can someone shed some light on this ...

I'm interested in utilizing Angular JS $anchorScroll to quickly navigate to the top of a page by using <a href>

Could you assist me in properly executing $anchorscroll with an href like this? Html: </div> <div> <a class="button" ng-click="scrollTo('section')" ng-href="#{{url}}" title="{{section}}">Next</a> </div> ...

The validation of the form does not seem to be functioning properly when the 'required' rule is used

I have implemented the Required form validation in my input fields to prevent submission with empty data. However, it seems like my required validation is not functioning as expected. function AddCar() { const [chasis, setChasis] = useState("" ...

Having trouble getting Bootstrap 5 modal to function properly in an Angular project

I'm currently working on integrating a modal into my Angular project. I've followed the example in the Bootstrap documentation and have also watched tutorials that suggest changing data-toggle to data-bs-target, but it's still not functionin ...

The onclick function in the Navbar div fails to work for inner elements

Within my navbar, there is a .dropbtn div that I want to trigger a dropdown function when clicked. However, only the text "TOTAL" seems to activate this function onclick. The <span> and <i> elements inside the .dropbtn do not respond to clicks ...

Perfecting the Radio Button Selection (because why not?)

Struggling to round the outer corners of three inline squared radio buttons with unique IDs. Need help fixing my CSS syntax - I can get each button to individually round its corners, but not just radio1 and radio3's outer corners. Check out the issue ...