I am struggling to make my Bootstrap 5 Navbar transparent. Can anyone help me figure this out?

I've been struggling with my Bootstrap Navbar, which appears as white no matter what I do. I've tried numerous solutions from Stack Overflow to make it transparent without any luck.

Even after setting the background to transparent and ensuring that the image behind it is set to VH100, the navbar remains stubbornly white. I've delved into the Inspect tool, targeting every color instruction I could find, but still no success. I also attempted removing the bg class from the navbar, thinking it might help.

Below is my HTML:

<nav class="navbar navbar-expand-sm navbar-light">
            <div class="container-fluid">
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
                  <span class="navbar-toggler-icon"></span>
                </button>
                <div class="collapse navbar-collapse" id="navbarTogglerDemo01">
            <a href="index.html" class="navbar-brand"><img src="/assets/images/MothersSpinesLogo.png" alt="Mothers Spines MS Logo"></a>
            <ul id="nav" class="navbar-nav ms-auto">
                <li class="active nav-item">
                    <a class="nav-link"href="index.html">HOME</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="about.html">ABOUT</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="contact.html">CONTACT</a>
                </li>
            </ul>
        </nav>

And here's my CSS:

/* Navigation */
.navbar-brand {
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    max-height: 60px;
    max-width: 60px;
    margin-left: 30px;
}

.navbar {
    align-items: end;
    background: none;
    background-color: rgba(0, 0, 0, 0.0);
    --bs-navbar-nav-link-padding-x: 3.5rem;
    font-family: 'Montserrat';
    font-size: 120%;
    list-style-type: none;
    letter-spacing: 1px;
    --bs-navbar-toggler-border-color: rgba(0, 0, 0, 0.0);
}


.navbar a {
    text-decoration: none;
    color: #252525;
}

.nav-item {
    padding-top: 25px;
}

Check out this screenshot of the Nav with Inspect open

Answer №1

  1. .navigation-bar { background-color: transparent; }
  2. Include the following in the picture: height: 100vh;, position: absolute; and top: 0;.

If you only apply height: 100vh; to the picture, it will fill the entire viewport height but will begin AFTER the navigation bar. To position it below the navbar, add position: absolute; and top: 0;.

In summary, the issue stems from the image itself.

Answer №2

There seems to be an issue with the placement of elements. The provided code does work for overlaying the image.

img#bg {
  position: absolute;
}


/* Navigation */

.navbar-brand {
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  max-height: 60px;
  max-width: 60px;
  margin-left: 30px;
}

.navbar {
  align-items: end;
  background: none;
  background-color: transparent;
  --bs-navbar-nav-link-padding-x: 3.5rem;
  font-family: 'Montserrat';
  font-size: 120%;
  list-style-type: none;
  letter-spacing: 1px;
  --bs-navbar-toggler-border-color: rgba(0, 0, 0, 0.0);
}

.navbar a {
  text-decoration: none;
  color: #252525;
}

.nav-item {
  padding-top: 25px;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="07656868737473756677473229372935">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

<img id="bg" src="https://st3.depositphotos.com/1021722/13762/i/600/depositphotos_137623752-stock-photo-art-spring-background-fresh-flower.jpg">

<nav class="navbar navbar-expand-sm navbar-light">
  <div class="container-fluid">
    <div class="collapse navbar-collapse" id="navbarTogglerDemo01">
      <a href="index.html" class="navbar-brand">
        <img alt="Mothers Spines MS Logo">
      </a>
      <ul id="nav" class="navbar-nav ms-auto">
        <li class="active nav-item">
          <a class="nav-link" href="index.html">HOME</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="about.html">ABOUT</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="contact.html">CONTACT</a>
        </li>
      </ul>
</nav>

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

oj-select-one displays a comprehensive list of values in the dropdown

Typically, oj-select-one will only display the first 15 values before requiring the user to search for more. Is there a way to show all values in the dropdown list without needing to use the search function? I attempted to use minimumResultsForSearch as s ...

Adding a custom source to the script tag in Angular 7

I am currently using angular cli to develop my web application. The app is being built in the dist folder as of now. This is the index.html file: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Adm ...

The SQLite database accessed through Flask exclusively returns variables, rather than actual data

I have a custom flask application that interacts with a sqlite database: @app.route('/<subject_id>') def subject_id_lookup(subject_id): entries = query_db('select visitdt, cvnotes from exam where id = ?', ...

Troubleshooting: My jQuery script for fading in content upon document ready is not

I'm currently working on a website where I want everything to fade in when the user enters the site. Take a look at my code: var celyLogin = $(".container"); $(document).ready(function () { /*! Fades in page on load */ $("container") ...

Steps to assign the identifier as the current index in the v-for iteration

Struggling to assign the id based on the index of a v-for loop. I attempted: <li v-for="(item, index) in items" v-bind:key="item.id"> <p>{{item.name}}</p> <input id= {{index}} type= "number"> < ...

What methods are available for updating the href color of an element using the DOM?

I am looking to update the color of a tab (Mathematics-tab) based on the value of 'aria-selected' changing to true in Bootstrap. I have multiple tabs, including one for mathematics, and I want to visually differentiate between selected and unsele ...

What is the reason why boolean attributes dont actually have a boolean value in HTML?

It's interesting that certain elements have boolean attributes. I find it curious why the values are not true/false or 1/0. Is there a specific reason for this design choice? <option selected="selected">Ham Burger</option> or <input ...

Revamp responsiveness in bootstrap 3 for printing with @media queries

My goal is to disable the responsive features of bootstrap when the event javascript:print() is triggered. This way, I want my webpage to maintain the column grid layout that I have defined, regardless of screen size. One solution suggested in this answer ...

Struggle with Firefox: Table-cell with Relative Positioning Not Acting as Parent

Upon investigation, I have come across a unique layout issue that seems to only affect Firefox. It appears that elements with display:table-cell; do not act as the positional parent for descendants with position:absolute;. It is surprising to discover th ...

Utilize JavaScript to extract content from a text file and showcase it in a Bootstrap modal pop-up through knockout binding

I'm currently working on a function that reads data from a .txt file (located in the website's root directory) and then displays it in a modal dialog box. I believe I've made progress as the file is recognized during debugging, but unfortuna ...

Looking to add some movement to your website? Learn how to make an image track your mouse pointer in a specific section of your webpage

I'm just starting out with web design and javascript, so please be patient. My goal is to have an image follow the mouse pointer only when it's within a specific section of my website. I've managed to make the image track the mouse cursor ...

How can I make a 100vh div stick to the screen?

Is there a way to fix a Google map in a div to the screen so that the map on the left side remains fixed while the content on the right side can scroll? I've tried using position:fixed but it doesn't seem to be working. See the pictures below for ...

I am interested in modifying the color of the tick marks on the input[range] element

Seeking Slider Customization Help I am eager to learn how to create and personalize a slider using HTML. Although many resources offer guidance on customizing the slider itself, I have yet to come across any information on customizing the scale. For insta ...

Exploring the concept of clip-path

Recently, I have been delving into the world of HTML and CSS, exploring clip-paths after stumbling upon them on this captivating website. My interpretation is that utilizing clip-paths, particularly with the polygon attribute, enables one to control which ...

Using XSLT to convert HTML into the desired text format

It has been almost two decades since my last encounter with XSLT. I am attempting to transform documents, like the HTML snippet below, into the desired output. <p> おばあさんは、とても <ruby><rb>喜</rb><rp>(</rp ...

Leverage CSS to generate a visually appealing table of contents incorporating images and text blocks, perfectly aligned for an enhanced

I am in the process of designing a unique clip showcase on my website. The concept involves creating a table-like structure with a thumbnail image on the left and various information on the right, including a title, publication source, date, and descriptio ...

The method of utilizing React with Redux to display component properties

I am currently trying to include my common component in my main.js file Successfully implemented this However, when attempting to print my Redux data values in the common component, I created a method called handleClickForRedux to handle this task. Even af ...

versatile grid tiles with CSS flexibility

Trying to remove the svg elements while keeping the grid layout intact. The svgs are used to maintain a 1:1 aspect ratio for all tiles. UPDATE: Discovered a CSS Solution for this. Simply set aspect-ratio: 1 for the tiles. Is there an alternative soluti ...

Unable to view Bootstrap Icons in Gulp 4

I recently integrated the new bootstrap icons npm package into my project using Gulp 4, the latest version. Everything was installed successfully and was working smoothly. However, I encountered an issue when trying to declare the icon in my index.html fi ...

Utilizing Gulp variables to create dynamic destination file names?

As a newcomer to gulp, I am curious about the feasibility of achieving my desired outcome. Here is the structure of my projects: root | components | | | component_1 | | styles.scss | | actions.js | | template.html | | ... | componen ...