Ways to darken a theme when displaying a pop-up

I recently added a pop-up feature to my portfolio website and utilized Bootstrap classes to enhance its functionality. In order to make the pop-up object more prominent, I wanted to darken the background when opening the pop-up. However, some elements in the background did not turn darker as expected. For a detailed understanding of my issue, please visit the following URL:

My portfolio website

Here is what I have tried:

  • Assigning the same id to the objects that I want to darken, and then adjusting their background color while displaying the pop-up.
 // JavaScript code
const theme = ['theme-change1', 'theme-change2', 'theme-change3', 'theme-change4', 'theme-change5', 'theme-change6', 'theme-change7', 'theme-change8', 'theme-change9',];

function showPopUp() {
  document.getElementById('pop-up').style.display = "block";
  document.body.style.backgroundColor = "rgba(0, 0, 0, .5)";
  document.getElementById('class-remover').classList.remove('bg-light'); 
  for(let i = 0; i < theme.length; i++){
    document.getElementById(theme[i]).style.backgroundColor = "rgba(0, 0, 0, .5)";
  }
}

function hidePopUp() {
  document.getElementById('pop-up').style.display = "none";
  document.body.style.backgroundColor = "white"; 
  document.getElementById('class-remover').classList.add('bg-light');
   for(let i = 0; i < theme.length; i++){
    document.getElementById(theme[i]).style.backgroundColor = "white";
  }
}      

Below is my current HTML code.

HTML:

 // HTML code
<!DOCTYPE html>
<html lang="en">
...
...
... (the remainder of the HTML content remains unchanged)
</body>
</html>

JavaScript:

// JavaScript code
function showPopUp() {
  document.getElementById('pop-up').style.display = "block";
  document.body.style.backgroundColor = "rgba(0, 0, 0, .5)";
  document.getElementById('class-remover').classList.remove('bg-light'); 
  document.getElementById('theme-change1').style.backgroundColor = "rgba(0, 0, 0, .5)";
  document.getElementById('theme-change2').style.backgroundColor = "rgba(0, 0, 0, .5)";
  ... (repeat for all theme IDs)
}

function hidePopUp() {
  document.getElementById('pop-up').style.display = "none";
  document.body.style.backgroundColor = "white"; 
  document.getElementById('class-remover').classList.add('bg-light');
  document.getElementById('theme-change1').style.backgroundColor = "white";
  ... (repeat for all theme IDs)
}

Answer №1

One potential solution could involve utilizing the unique identifier modal-backdrop-dark.

To further illustrate this concept, please refer to the following real-time demonstration: here

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

Extracting Values from a jQuery Array Object

Good day everyone! Here is the code I am currently working with: var items = []; $(xml).find("Placemark").each(function () { var tmp_latLng = $(this).find("coordinates").text(); tmp_latLng = tmp_latLng.split(","); items.push({ name: ...

What causes the width of input fields to increase as more inputs are added in flexbox?

I'm working on a form that consists of multiple sections, each with varying numbers of input fields. I've noticed that when I apply display: flex to the parent div and set the input fields to 100% width, the widths are calculated differently depe ...

What is the best way to extract text that falls between two specific patterns using the preg_match_all function in PHP

I've been struggling to locate two specific HTML tags and extract the content in between them. When I search for each tag individually, they are found successfully, so I am confident that they are spelled correctly and do exist. However, I believe the ...

Problem encountered when attempting to utilize the spread operator within .vue files in an Elixir Phoenix 1.3 application

I'm facing an issue while building Vue.js components that involve using the spread operator to map states from Vuex within my Phoenix 1.3 application. The JavaScript compile errors I encountered are causing some roadblocks: 26 | }, 27 | compu ...

Unexpected error from API call detected within Mint localhost Template Kits elements

Hello Everyone, hope you're all having a good day! Recently, I installed the Elementor and Envato Elements plugins on my localhost Linux Mint WordPress setup. After configuring permalinks and other settings in WordPress, I proceeded to browse Templat ...

I am having trouble getting all the HTML content to properly display in the GitHub zip file

I am encountering an issue where the index.html file is not displaying the navigation or images as expected. For reference, the project can be found at https://github.com/LawlietBlack/Persona-4-Golden-Guide If there is a more appropriate place to ask this ...

What is the best way to create a table by selecting a number at random from a shuffled array of 16 numbers and then incorporating it into the HTML code

I'm trying to display a table in HTML with 16 cells containing numbers from 1 to 16 in a random order. I am having trouble implementing the part where I need to pop a number from the array. Any help would be greatly appreciated :) Here's the cod ...

Internet Explorer 7 is having trouble loading JavaScript

I'm encountering an issue with loading JQuery in IE7, it works smoothly in all other browsers such as Firefox, Safari, Opera, and IE8, except for IE7. If anyone has any insights on why this might be happening, please share your thoughts. Thank you, ...

What is the mechanism behind the functioning of StackOverflow's notification system?

Could you explain the technique that is utilized to transmit and receive data from the client to the server? How does it manage to provide almost real-time results when new changes take place? Can anyone demonstrate the code being used for this process? ...

a guide to presenting information in a horizontal layout within a single table using the Laravel framework and Vue.js

I have 2 tables: table 1 ________________ | name_id name | | 1 john | | 2 heaven | |_______________| table 2 _______________________ | id name_id product | | 1 1 bag | | 2 1 shoes | |______ ...

No information is being emitted by the subject

In my application, I have a feature where users input data that needs to be validated in a form. Once the validation is successful, a button is enabled allowing the user to submit their order. However, I'm facing an issue with this specific component ...

Can you explain the distinction between "javascript:;" and "javascript:" when used in the href attribute?

Can you explain the distinction between using "javascript:;" and just "javascript:" within an anchor tag's href attribute? ...

The drag functionality can only be used once when applied to two separate div elements

Recently, I came across an issue where I have both an Image and a custom text element placed between them using an input box. My goal is to make both the text and the image draggable on the page. However, I noticed that while the image can be dragged and d ...

Phonegap enables iOS keyboard to dynamically adjust screen size during use

Currently, I am developing an iOS app using phonegap 3.0 and have encountered a particular issue. In my app, there is a window where users are required to enter a promo code. The problem arises when I click on the input area (see this example) and then pr ...

Extract information from the webpage

Having my own external website, I am looking to extract data from it. Initially, I used CURL to retrieve the website's content but now I specifically need to extract the TimeStamp of a Facebook page. By inspecting the element on the page, you can find ...

Retrieving Object ID in the Current Page with Vue.js After Making a POST Request

My goal is to have the functionality of Saving and Editing on the same page. Since I have a large number of input fields, I want to be able to Save with just a few fields without being Redirected to another page. The main thing I need is to retrieve the c ...

CSS - positioning the sidebar on the far left edge of the screen (refer to image)

Is there a way to create a layout similar to this design: https://i.sstatic.net/yjkeD.png For a demonstration, see here: http://jsfiddle.net/ymC82/ Current HTML code: <div class="wrapper"> <aside> Sidebar </aside& ...

Waiting for JavaScript/Vue/Angular to finish loading using Selenium in Java

I am currently developing an automation tool for a website using Selenium in Java. To enhance the real automation process, I heavily rely on JavaScript with JavascriptExecutor. While things usually run smoothly, there are occasional crashes (around 1 out o ...

Alter regular expression matches within the new string replacement

I am having an issue with using regex to extract URLs from a text and then modifying all the matches within the replacement string using a function. Below is a simplified example of what I am trying to accomplish. Is it possible to achieve something lik ...

Setting global variable values when a button is clicked in Javascript

My query involves JavaScript. I have an HTML template with a button (b1) that, when clicked, assigns an array to a variable called tempdata. The issue arises when trying to display this tempdata array using alert() outside the onclick function; nothing hap ...