What could be causing a fixed pseudo-element to interfere with clicks on my website?

After updating my website to Bootstrap5, I noticed that one of the pages was not behaving correctly. Upon investigation, I found that the issue was related to this particular block of CSS:

body:before {
    content: '';
    position: fixed;
    width: 100vw;
    height: 100vh;
    top: 0;
    box-shadow: inset 0 0 100px 20px #14BD63;
}

Interestingly, the presence of this CSS seems to interfere with the functionality of a button on the page. Removing the CSS allows the button to function as expected. What could be causing this conflict?

html,
body {
  margin: 0;
  padding: 0 0 0 0;
}

body:before {
  content: '';
  position: fixed;
  width: 100vw;
  height: 100vh;
  top: 0;
  box-shadow: inset 0 0 100px 20px #14BD63;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ed8f8282999e999f8c9dadd8c3dfc3dd">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">

<!-- Wrapper container -->
<div class="container py-4">

  <!-- Bootstrap 5 starter form -->
  <form id="contactForm">

    <div class="row">
      <div class="col text-center my-auto">
        <button type="button" class="btn btn-outline-info btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
          <span class="fa fa-calendar"></span>&nbsp;Cohort Year
        </button>
        <ul id="ddCohort" class="dropdown-menu csr_lnk" style="">
          <li>&nbsp;<input type="checkbox" class="d-inline ddCohort" id="inpCohort2026" value="2026" onclick="ddUserSelectedCohortChanged(this.value);"><label for="inpCohort2026" class="d-inline input small dropdownLabel_NormalFont">2026</label></li>
          <li>&nbsp;<input type="checkbox" class="d-inline ddCohort" id="inpCohort2025" value="2025" onclick="ddUserSelectedCohortChanged(this.value);"><label for="inpCohort2025" class="d-inline input small dropdownLabel_NormalFont">2025</label></li>
          <li>&nbsp;<input type="checkbox" class="d-inline ddCohort" id="inpCohort2024" value="2024" onclick="ddUserSelectedCohortChanged(this.value);"><label for="inpCohort2024" class="d-inline input small dropdownLabel_NormalFont">2024</label></li>
          <li>&nbsp;<input type="checkbox" class="d-inline ddCohort" id="inpCohort2023" value="2023" checked="" onclick="ddUserSelectedCohortChanged(this.value);"><label for="inpCohort2023" class="d-inline input small dropdownLabel_NormalFont">2023</label></li>
          <li>&nbsp;<input type="checkbox" class="d-inline ddCohort" id="inpCohort2022" value="2022" onclick="ddUserSelectedCohortChanged(this.value);"><label for="inpCohort2022" class="d-inline input small dropdownLabel_NormalFont">2022</label></li>
        </ul>

      </div>
    </div>
  </form>
</div>

<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="30525f5f44434442514070051e021e00">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>

Answer №1

Your background is appearing over the page due to its positioning, affecting the stacking order. One fix is to assign it a z-index of -1.

html,
body {
  margin: 0;
  padding: 0 0 0 0;
}

body:before {
  content: '';
  position: fixed;
  width: 100vw;
  height: 100vh;
  top: 0;
  box-shadow: inset 0 0 100px 20px #14BD63;
  z-index: -1;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="791b16160d0a0d0b1809394c574b5749">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">

<!-- Wrapper container -->
<div class="container py-4">

  <!-- Bootstrap 5 starter form -->
  <form id="contactForm">

    <div class="row">
      <div class="col text-center my-auto">
        <button type="button" class="btn btn-outline-info btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
          <span class="fa fa-calendar"></span>&nbsp;Cohort Year
        </button>
        <ul id="ddCohort" class="dropdown-menu csr_lnk" style="">
          <li>&nbsp;<input type="checkbox" class="d-inline ddCohort" id="inpCohort2026" value="2026" onclick="ddUserSelectedCohortChanged(this.value);"><label for="inpCohort2026" class="d-inline input small dropdownLabel_NormalFont">2026</label></li>
          <li>&nbsp;<input type="checkbox" class="d-inline ddCohort" id="inpCohort2025" value="2025" onclick="ddUserSelectedCohortChanged(this.value);"><label for="inpCohort2025" class="d-inline input small dropdownLabel_NormalFont">2025</label></li>
          <li>&nbsp;<input type="checkbox" class="d-inline ddCohort" id="inpCohort2024" value="2024" onclick="ddUserSelectedCohortChanged(this.value);"><label for="inpCohort2024" class="d-inline input small dropdownLabel_NormalFont">2024</label></li>
          <li>&nbsp;<input type="checkbox" class="d-inline ddCohort" id="inpCohort2023" value="2023" checked="" onclick="ddUserSelectedCohortChanged(this.value);"><label for="inpCohort2023" class="d-inline input small dropdownLabel_NormalFont">2023</label></li>
          <li>&nbsp;<input type="checkbox" class="d-inline ddCohort" id="inpCohort2022" value="2022" onclick="ddUserSelectedCohortChanged(this.value);"><label for="inpCohort2022" class="d-inline input small dropdownLabel_NormalFont">2022</label></li>
        </ul>

      </div>
    </div>
  </form>
</div>

<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8be9e4e4fff8fff9eafbcbbea5b9a5bb">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>

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

What purpose is served by the use of '.src' in Next.js?

When working with Next.js, I encountered a situation where I needed to set a background image. After doing some research, I came across a solution that involved adding .src at the end of the image reference like this: import bgImg from '../public/imag ...

Discovering the true width of elements that have overflow hidden in IE7 using jQuery

I am dealing with a dynamic list that contains around 50 elements, but the exact number may vary. <div style="width:465px;"> <ul> <li>aaa</li> <li>aaa</li> <li>aaa</li> <li>aaa& ...

The HR tag does not display anything following the mailing

Struggling to design a newsletter template with different lines for each product using the HR tag. However, none of my attempts with divs, tables, or CSS properties have been successful. The template looks fine in Chrome, but when sent to the provider, th ...

Enhance the appearance of Font Awesome stars by incorporating a hover effect

Is there a straightforward way to make them turn solid yellow when you hover over them? const styles = theme => ({ root: { flexGrow: 1, overflow: 'hidden', padding: theme.spacing(0, 3), }, paper: { maxWidth: 800, mar ...

Saving Style Sheets in a Database

Currently, I am interested in saving CSS data in a mySql database as part of my LAMP setup. My intention is to create an input field that includes the following code: body{ background: url("http://google.com/image.jpg") no-repeat; color: orange; } #someDi ...

Steps to incorporate a personalized design onto a card element within Material UI

As a JavaScript developer, I was tasked by my brother to create a simple webpage for his business. Admittedly, frontend design is not my strongest suit so I decided to utilize Material UI and added some CSS to paste everything together. Right now, I am wo ...

Need help fixing my issue with the try-catch functionality in my calculator program

Can someone assist me with my Vue.js calculator issue? I am facing a problem where the output gets added to the expression after using try and catch. How can I ensure that both ERR and the output are displayed in the {{output}} section? Any help would be a ...

In JavaScript, you can update the class named "active" to become the active attribute for a link

My current menu uses superfish, but it lacks an active class to highlight the current page tab. To rectify this, I implemented the following JavaScript code. <script type="text/javascript"> var path = window.location.pathname.split('/'); p ...

Trouble with bootstrap 5 nested accordions: panels won't collapse as expected

I've structured my page content using nested bootstrap accordions within Bootstrap 5. The primary accordion is organized by continents, with each panel containing a secondary accordion for individual countries. While the main accordion functions cor ...

Automatically changing the page's background color through animation upon loading

Similar Question: jQuery animate backgroundColor Can I make the background-color of a specific element change gradually when the page loads? I have a webpage with content like this: <ul> <li> Some stuff</li> <li> Some ...

How come characteristics of one particular div element are transferring to unrelated div elements?

Recently, I created a small practice website and encountered an issue that is quite frustrating. Here's the div structure I used: <div class="work-process"> <div class="container" align="center"> <div class="col- ...

Adjust the translateZ value according to the dynamic height of the element

A unique rotating cube effect has been developed using 3D css transformations. To achieve this, the following transform is applied to a child element: transform: translateY(-50%) translateZ(-75px) rotateX(90deg) ; In addition, the parent element contain ...

Error: The locator I used with the ID getUserById did not find any elements

Here is the code snippet from my HTML file: <h1>User list</h1> <button class="btn btn-primary" [routerLink]="'/register'">Register</button> <br> <br> <table class="table& ...

The Lighthouse tool consistently indicates a high Cumulative Layout Shift (CLS) score, even after adjusting

On the Lighthouse report, Cumulative Layout Shift shows a high number: 0.546 Upon analyzing the trace, I noticed that the image block initially does not take up the required space and pushes down the content below. Refer to the image: https://i.sstatic.ne ...

Customizing Carousel Arrows in Angular with ng-bootstrap

I need help changing the position and icon of control arrows using Bootstrap. I've tried targeting "carousel-control-prev-icon" & "carousel-control-next-icon", but nothing seems to work. Any suggestions on how to properly solve this issue? Here is th ...

Issues with Disabling the Browser's Back Button with jquery

I have been attempting to prevent the back button from functioning in a specific Browser, Microsoft Bing. Interestingly, my code works only if I click somewhere in the window first. If I don't click anywhere and try to go back directly, it still allow ...

Exploring Nested CSS Grids and Resizing Images on the Web

Having an issue resizing images in CSS Grid. I set up a main layout with 2 columns, and within the first column is another grid where I intended to place an image and some text. Please remove the html comment so you can see the image. The problem lies i ...

Softening the edges of a table

Could you assist me in rounding the corners of my table? I attempted using the basic border-radius, however, it only separated the border at the corners. Do you think this issue is due to my browser (Firefox) or could it be a bug? You can view my Jsfiddl ...

Sentence following the original passage

I want to achieve a similar look as the example below: Here is what I have done so far: h2:after { content: ""; display: inline-block; height: 0.5em; vertical-align: bottom; width: 48px; margin-right: -100%; margin-left: 10px; border-bo ...

Conceal the Download Button Effectively

I operate a website for playing audio files and I am looking to prevent users from downloading the sounds using the download button in the HTML audio element. Here is what I came up with: <audio src="sound.mp3" controls controlsList="nodownload">< ...