HTML Opacity Error Detected

I have successfully added a background opacity, but now I am facing an issue where the bar buttons are not clickable. I want only the background to have 0.5 opacity, not affect the entire website.

#background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://i.ytimg.com/vi/3KNQfA21QyQ/maxresdefault.jpg');
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: 100%;
    opacity: 0.5;
    filter:alpha(opacity=80);
}
ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #333;
}

li {
    float: left;
}

li a, .dropbtn {
    display: inline-block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

li a:hover, .dropdown:hover .dropbtn {
    background-color: red;
}

li.dropdown {
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
}

.dropdown-content a:hover {background-color: #f1f1f1}

.dropdown:hover .dropdown-content {
    display: block;
}
<ul>
  <li class="dropdown">
    <a href="javascript:void(0)" class="dropbtn">Dropdown</a>
    <div class="dropdown-content">
      <a href="#">Link 1</a>
      <a href="#">Link 2</a>
      <a href="#">Link 3</a>
    </div>
</li>
  <li class="dropdown">
    <a href="javascript:void(0)" class="dropbtn">Home</a>
    <div class="dropdown-content">
      <a href="#">Link 1</a>
      <a href="#">Link 2</a>
      <a href="#">Link 3</a>
    </div>
</li>
  <li class="dropdown">
    <a href="javascript:void(0)" class="dropbtn">News</a>
    <div class="dropdown-content">
      <a href="#">Link 1</a>
      <a href="#">Link 2</a>
      <a href="#">Link 3</a>
    </div>
  </li>
</ul>

Answer №1

Your CSS is decent, but the issue lies within your HTML structure. Make sure to organize the body section properly before moving on with the rest:

<body class="my-container" bgcolor="black">
<ul>
<li class="dropdown">
<a href="javascript:void(0)" class="dropbtn">dropdown</a>
<div class="dropdown-content">
  <a href="#">Link 1</a>
  <a href="#">Link 2</a>
  <a href="#">Link 3</a>
</div>
</li>
</ul>
<div id="background"></div>
</body>

After that, adjust the z-index of #background to ensure it remains behind your entire layout:

ul { position: relative; z-index: 3; }
#background { position: fixed; z-index: 1; }

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

Accordion content from MUI gets cut off by bookmark bar when expanded

How can I prevent an MUI accordion in an appBar from moving up and hiding behind the browser's bookmark bar when expanded? const useStyles = makeStyles((theme)) => { appBar: { borderBottom: "2px solid #D2D2D2", backgro ...

By default, the select option in AngularJS will have a value of either an object or null

This block of code is located in the js file: $scope.ListOption = []; $scope.ListOption.push({ Value: "0", Name: Car }); $scope.ListOption.push({ Value: "1", Name: House }); Below is the corresponding HTML code: <select class="form-control" id="Categ ...

How can I populate the second Select tag based on the selection made in the first Select tag using AngularJS

I am currently utilizing UI-Bootstrap in order to seamlessly integrate Angular and Bootstrap functionalities. My goal is to extract the value from a select tag contained within the "controllerCountries" controller, and then utilize that value as a paramete ...

Enable access to the child of Lages and apply CSS to disable it

My current code looks something like this: <label for="billing:postcode" class="required"><em>*</em>Zip/Postal Code</label> I am looking to hide the <em> element from displaying using CSS. How can I achieve this with the dis ...

Retrieving the onclick value in Selenium without the need to physically click the

Is there a way to access a value from a website without actually clicking on it? I need this specific value but due to bot blockers, interacting too much with the site is not an option. When inspecting the page by pressing F12, I can see the value I need i ...

Issue encountered with JavaScript function within TypeScript file connected to HTML code

I am currently working on a simple SharePoint web part and encountering an issue with using a function from another module file in my main file. Snippet from the JSFunctions.module.js file (where I define my function): function getApi(){ [my code]... }; ...

Ways to incorporate a border line between a pair of icons within a bootstrap card

Incorporating a border line within the card-header is my current goal. My approach involves positioning two icons - one on the left side and the other on the right. Illustrative example below: https://i.sstatic.net/BgxVu.png Utilizing HMTL and CSS to ac ...

What is the best way to trigger the opening of this modal after a certain amount

I'm currently working on a CSS and HTML modal and I'd like it to appear 3 seconds after the page loads using jQuery. I'm struggling to find the right event handler for this task. How can I achieve this effectively? Check out the modal desig ...

What is the best way to access the width property within the style attribute of a span element with a specific class

https://i.sstatic.net/1YQdP.png Currently, I'm attempting to extract the content inside "width: 100%" and specifically the numerical part. My approach involves using beautifulsoup in Python, and you can see the snippet of my code below: rat ...

Develop a stylish contact form using a mixture of HTML5, Bootstrap, and Php

On my website, I have created a contact us form using HTML, Bootstrap, and PHP. The form functions correctly, and messages are successfully received. However, the issue is that upon clicking the submit button, a new page opens up displaying a "Thank you me ...

What is the best method for retrieving data using Selenium when the class name may vary slightly?

Hypothetically, let's consider the following HTML code snippet displayed on a website: <div class="box"> <div class="a1"></div> <div class="a2"></div> <div class="a3" ...

The paragraph tag closes automatically once opened

In the process of establishing a news section on my website, I encountered an issue while using the following code: <p id="news-container"> <h1> . . . </h1> <strong>big</strong> . . . </p> Upon inspecting, it appea ...

Two buttons next to each other positioned below my magnified picture

I'm currently working on implementing a feature where clicking an image enlarges it and displays two buttons at the bottom, but I'm facing some challenges with getting the buttons to show up. Any assistance would be greatly appreciated! Addition ...

Bootstrap 4 Carousel Properly Aligned on Small Screens

I am facing an issue with the carousel display. It appears perfectly centered on desktop and laptop screens but shifts to the right on mobile devices. I checked using Chrome developer tools and everything seems aligned correctly within the container. Here ...

The issue with React map causing a duplication of DOM Elements is persisting

I am encountering a particular issue: Currently, I am developing a web application with the BackEnd in spring and FrontEnd in React. The new feature I am implementing involves displaying the number of products in the cart when the client clicks on "buy". ...

Looking to switch up the header color on your website?

Is there a way to update the color of the header on this website () without using JavaScript? I only have knowledge in HTML and cannot locate the red color in any js file from c.sitagabriel.com. I attempted to modify the style.css but it did not result in ...

Detecting preview URLs sent by SMS clients

Recently, users of my app have identified a situation that occurred over two years ago. In a nutshell, a URL link is sent to the customer which, upon clicking, executes certain actions based on an encrypted key passed in the URL query string. Originally, ...

No information was retrieved from the Wikipedia server after sending an HTTP request

I have been trying to fetch HTML using code. It works perfectly fine when fetching from "http://www.google.com," but when attempting to fetch from "http://en.wikipedia.org/w/api.php," I am not getting any results. Any ideas on what might be causing this i ...

What is the best approach to create a JavaScript search filter function spanning two pages?

Page1.html has a form with a drop-down menu containing options Color and Shape. There is also a submit button. Assuming Page2.html displays various shapes like Blue Square, Red Square, Blue Circle, Red Circle, is it feasible to create a JavaScript file th ...

Steps to ensure checkboxes are enabled for selection only when another box has been checked

Consider having 3 checkboxes: 1 'parent' checkbox and 2 'child' checkboxes. If the parent checkbox is selected, you should be able to select either or both of the child checkboxes. If the parent checkbox is deselected, neither of the ...