For my website's navigation bar, I utilized Bootstrap 4. Despite my efforts, I encountered difficulty in modifying the background color of the enclosing div element

After experimenting with a few different options such as setting the background-color to transparent, rgba(0,0,0,0), and background: none; I found that when I used background-color: red or any other color, the color changed as expected.

Below is the HTML code I used:

`<div class="navbar  navbar-expand-md">
  <h1 class="navbar-brand">sivarajbiz</h1>
  <ul class="navbar-nav">
    <li class="nav-item"><a href="#" class="nav-link">Home</a> </li>
    <li class="nav-item"><a href="#" class="nav-link">What you want</a> </li>
    <li class="nav-item"><a href="#" class="nav-link">What I know</a></li>
    <li class="nav-item"><a href="#" class="nav-link">Let's chat</a> </li>
  </ul>
</div>`

Here is my CSS code:

:root{
  --primary-theme-color: #0077B5 /*LinkedInBlue*/;
  --buttons-color: #0077B5 /*LinkedInBlue*/;
  --primary-bg-color: black;
  --primary-font-color: white;
  --img-text-bg-color: rgb(0,0,0,0.2);
  --img-text-font-size-mobile: 0.8em;
  --img-text-box-width: 20em;
  --img-text-box-width-mobile: 15em;
}

body{
  font-family: "times new roman",serif;
  color: var(--primary-font-color);
  background-color: var(--primary-bg-color);
}

.carousel-inner .carousel-item {
  height: 100vh;
}

.carousel-caption{
  transform: translate(-5vw,-30vh);
  background-color: var(--img-text-bg-color);
  width: var(--img-text-box-width);
  height: var(--img-text-box-width);
  text-align: left;
  padding-left: 2%;
}

Upon inspection, you can see from the screenshot that the navbar is originally black in color. I intended to change it to appear transparent, but encountered difficulties.

https://i.sstatic.net/6beTm.jpg

Answer №1

If I have understood correctly...

By carefully examining your CSS, you may notice that the body color is set to black. Therefore, if you keep the body transparent, the CSS will still apply and the color will remain black.

If you want to set the background as transparent (to display the image as a background instead), you should set the body to transparent like this:

body {
 background-color: transparent;
}

Answer №2

If you want to get rid of the background color, simply delete the line

background-color: var(--primary-bg-color);
from your body style. Take a look at this example on Codepen https://codepen.io/irinnahar/pen/NZOqjO

Answer №3

Shifting the background image to the top with top: 0; and introducing a z-index of z-index:10; to the navbar element successfully resolved the issue. As a result, the navbar now displays the portion of the image that is positioned behind it as its background.

Answer №4

Have you considered using the css!important declaration?


For example:

background-color:rgba(255,0,0,1) !important;

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

Transform your image using the Bootstrap framework

I am attempting to create a similar banner using bootstrap. You can view the demo of the banner here. https://i.stack.imgur.com/JXLNY.png I'm struggling to understand how to achieve this in bootstrap 3 and where to begin. Should I use rows and colum ...

Tips for concealing JavaScript animations beyond specific boundaries?

So I'm delving into the world of javascript/jquery and an amazing idea popped into my head for a webpage effect. Let me break down the design a bit. My website is neatly contained within a wrapper div, ensuring that the content stays at 1000px and ce ...

Check for the presence of a file in the directory and if it exists, load

Attempting to explain this query may lead to confusion. I have been searching for an answer for approximately three days with no success. It appears that the task at hand is either impossible or so straightforward that no one has encountered the need to in ...

Check out this chat box layout showcasing messages from both senders and receivers

Currently, the code is functional but it shows both the sender and receiver messages in the same color. I would like the sender's color to be different from the receiver's message color. <?php require_once 'cn.php'; session_star ...

Is it possible to apply border-radius to selections, similar to how it is done in vscode

It was reminiscent of this... Visual Studio Code ::selection{ border-radius: 5px; } I attempted something similar to this, however it was not successful... ...

Is there a way to adjust the transparency of individual words in text as you scroll down a page, similar to the effect on https://joincly

Is there a way to achieve a text filling effect on page scroll similar to the one found here: . The specific section reads: "Deepen customer relationships. Own the brand experience. Add high margin revenue. Manage it all in one place. Get back your pr ...

Incorporate additional form element functionalities using radio inputs

Recently, I created code that allows a user to duplicate form elements and add values by clicking on "add more". Everything is functioning properly except for the radio inputs. I am currently stuck on this issue. Does anyone have any suggestions on how I c ...

Is it possible to alter the color of the text "midway" within a character on a website?

In some desktop applications, I've noticed a cool feature where the color of text changes as the background evolves. This allows for multiple colors on a single character, which is especially useful when displaying progress bars with percentages insid ...

What could be causing the lack of space between the elements of form-inline?

Check out the demo here: http://jsfiddle.net/sunnycpp/MPACc/4/ Here is the same code pasted below: HTML <div class="container"> <debug-bar ng-controller="parentController"> <debug-bar ng-controller="childController"> <deb ...

What are the steps to modify the "text" displayed on a button in a kendo grid?

How can I change the default button text "add new record" on my kendo grid? I attempted to modify it using the following code, but it did not work: #turbinegrid .k-icon.k-add::after { content: "ADD"; } ...

Increasing Gap between Tabs in Primefaces AccordionPanel: A Guide

Is there a way to increase the spacing between the tabs of a Primefaces AccordionPanel component? ...

Customize the background color of selected date in MUI DatePicker 6.19.7 with sx styling

Looking to update the color of a specific element highlighted by an arrow using sx{} DatePicker <LocalizationProvider dateAdapter={AdapterDayjs}> <DatePicker className={styles.picker} ...

Sorting across several lists leads back to the initial list

I currently have multiple lists, with each list and item sharing the same class. For example: <ul class="cat_1"> <li class="cat_1">Item1</li> <li class="cat_1">Item2</li> <li class="cat_1">Item2</li> ...

How to perfectly align a full-width div with a div of specific width

Consider this scenario: .d1 { width: 100px; float: left; } .d2 { width: auto; float: left; } <div class="d1">Fixed Content</div> <div class="d2">This content should expand to fill the rest of the page vertically.</div> This setu ...

Size of text Including line breaks

I have developed a function that calculates the maximum size of text: function CalculateMaxTextSize(width, height, text) { var ourText = $('span').css('font-weight', 'bold').text(text); ...

Confirm that only the days of the present month are eligible for selection

I have been given the responsibility of validating a date field that is populated when an invoice is created. The date field consists of a text box and three button objects allowing users to select a date from a calendar, input today's date, or remove ...

What is the best way to position a div at the bottom of a web page?

I have a question that may seem basic, but I've been struggling to find a solution. Despite searching for answers, none of the suggestions I've come across have worked for me. My application has two main containers - a header and a content div. T ...

Mastering the art of incorporating live JavaScript search functionality that updates in real-time as the user continues typing on the same

Trying to implement a JavaScript search feature to find a div within the same page. The current code being used for the search query display is: $('.form-search').on('submit',function(){return false;}); $('.form-search .btn') ...

The seamless flow of web design

Seeking guidance on creating a responsive web page. I have a functional website that looks great on my 13" MacBook, but encounters distortion at different screen sizes. What steps are necessary to ensure it appears crisp and appealing on any device? Should ...

What is the best method to modify the accurate phone number within my script?

I need help with a text format script. link HTML CODE: <label for="primary_phone">Primary Phone Number<span class="star">*</span></label> <br> <input type="text" name="primary_phone" id="primary_phone" class="_phone requ ...