How come my "Pop-up box" doesn't appear when clicked a second time?

Although the code above works perfectly when I run it, it causes errors on my website. The issue I'm facing is that on the first click, all links work fine. However, when I try to click a second time, it shows a blank page and I can't click anywhere on the page. I have to either refresh the page or click the back button.

.overlay {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  transition: opacity 500ms;
  visibility: hidden;
  opacity: 0;
    overflow:hidden;
  z-index:9999999;
}
.overlay:target {
  visibility: visible;
  opacity: 1;
}

.popup {
  margin: 70px auto;
  padding: 20px;
  background: #fff;
  border-radius: 5px;
  width: 30%;
  position: relative;
  transition: all 5s ease-in-out;

}

.popup h2 {
  margin-top: 0;
  color: #333;
  font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
  position: absolute;
  top: 20px;
  right: 30px;
  transition: all 200ms;
  font-size: 30px;
  font-weight: bold;
  text-decoration: none;
  color: #000;
}
.popup .close:hover {
  color: #06D85F;
}
.popup .content {
  max-height: 30%;
  overflow: auto;
}

@media screen and (max-width: 700px){

  .popup{
    width: 70%;
  }
}
<div style="clear:both; height:23px; font-size:9px; color:#0033FF; text-align:right; margin-right:11px;"><a href="#1" >View</a></div>
                          <div id="1" class="overlay">
<div class="popup">
<h2>pop up window one </h2>
<a class="close" href="#" >&times;</a>
<div class="content">
this is my pop up window 1
</div>
</div>
</div>


<div style="clear:both; height:23px; font-size:9px; color:#0033FF; text-align:right; margin-right:11px;"><a href="#2" >View</a></div>
                          <div id="2" class="overlay">
<div class="popup">
<h2>pop up window one </h2>
<a class="close" href="#" >&times;</a>
<div class="content">
this is my pop up window 1
</div>
</div>
</div>



<div style="clear:both; height:23px; font-size:9px; color:#0033FF; text-align:right; margin-right:11px;"><a href="#3" >View 3</a></div>
                          <div id="3" class="overlay">
<div class="popup">
<h2>pop up window one </h2>
<a class="close" href="#" >&times;</a>
<div class="content">
this is my pop up window 1
</div>
</div>
</div>

Answer №1

Upon following your instructions, it appears that there is a issue with the theme.js file on your website.

When you click the close "x" button on the popup, a function located at line number 105 in that file is triggered. This function adds inline css to your popup, reducing the opacity of the popup div to "opacity:0".

Resolution: You have the option to simply modify the class name and remove the click event as a temporary fix. Alternatively, you can make changes to the theme.js file, optimize your code, and enhance performance...

The decision is up to you. I trust this information will be of assistance to you. Feel free to reach out if you require further assistance! Thank you!

Happy Coding!!!

Answer №2

This code snippet appears to be functioning correctly on Stack Overflow. It's possible that the issue lies within your local environment.

If you require any assistance, don't hesitate to reach out to me!

Thanks and happy coding!

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

Approach to CSS Layout: Creating Rounded Corners without CSS3 using images on all sides

I am faced with the challenge of creating a CSS layout that must adhere to specific minimum width and height requirements, yet expand to occupy 80% of the browser size. The main div I need to design should have rounded corners, utilizing images due to lack ...

Extracting data from a textbox in a PHP view and passing it to the controller

Is there a way to retrieve the values entered in a text box on a webpage and pass them to a PHP controller for display? VIEW <input type="text" name="Quantity" id="Quantity" value="" /> CONTROLLER function cartoutput() {//echo "hi"; $category ...

Angular: Ensuring Paypal button does not display twice without a hard reload

I have encountered an issue with a PayPal payment button on my page. The button displays fine when I generate it for the first time, but if I try to generate it again for another order, it doesn't show up. I have to hard reload the page to get it to w ...

What is the method to ensure span elements wrap text without setting a specific width or maximum width on the parent div?

Here is a snippet of code I have generated for displaying warnings or errors in Dojo dialogs: /* Relevant CSS styles */ .l-status-message-wrapper { height: auto; margin-left: 5px; margin-top: 2px; min-height: 15px; } .l-status-message-w ...

Implementing a function to load HTML pages upon clicking a button with JavaScript

I need help creating a button that loads an HTML page using JavaScript, without redirecting to the page. However, the current code I have is not loading the HTML page as desired. Here is the code snippet in question: <!DOCTYPE html> <html> &l ...

javascript mobile nav event

My website utilizes a bootstrap feature for mobile devices where a left sidebar pops up when clicking a button. I am not very familiar with bootstrap, but I would like to link a javascript event to determine if the left sidebar is visible. How can I achiev ...

The issue with border radius property on the scrollbar of a bootstrap dropdown menu

Is the scroll bar of a bootstrap dropdown menu sticking out of the box when using the border radius property? Looking for a solution? Check out this example code and preview: <div class="container py-4"> <div class="dropdo ...

Display information from a MySQL database in a tabular format using PHP

I am currently learning PHP and attempting to retrieve data from a database to display it in an HTML table. However, I am facing an issue where the total number of records returned is 13 but only 12 records are being displayed in the table (it seems to be ...

Using Javascript, delete all chosen HTML elements containing innerText

Looking to extract certain HTML tags from a block of code in TextArea1 and display the modified output in TextArea2 upon clicking a button. <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8&quo ...

Automating testing for numbered lists with CSS list-style-type decimal

I need help with a JavaScript and CSS project. I have a situation where I have a numbered list like this: Coffee Tea Cola Here is the code structure I am using: <!DOCTYPE html> <html> <head> <style> ul.a {list-style-type ...

Is it possible to utilize CSS to form a triangle outline on the right-hand side of a Bootstrap list group?

https://i.sstatic.net/vSoa0.png Hey everyone! I'm trying to achieve a triangle shape using CSS at the end of a list item. I've utilized the list group component from Bootstrap to display my list. Below is a snippet of my code. I've als ...

"Can someone guide me on the process of transmitting data to a client using Node in combination with

I am new to web development and struggling to understand how to transfer data from the Node server to the client while also displaying an HTML page. I am aware that res.send() is used to send data, but I'm having difficulty maintaining the client disp ...

Here's a way to programmatically append the same icon to multiple li elements generated using document.createElement:

I am new to creating a to-do app and need some guidance. When a user enters a task, I successfully create a list item for that task. However, I am unsure how to add a delete icon next to the newly created li element. Can someone please help me out? Below ...

Is there a way for me to determine the value or array that has been passed in the form?

I am facing a challenge and need help solving it. I have a project that involves interacting with a database, where I created a CRUD HTML table for data manipulation. There are 15 tables in the relative database, and I need to insert, delete, and edit reco ...

Combining HTML, CSS, and ASP.NET is a

<table cellspacing="0" cellpadding="0" width="100%" style="background-image: url('/ProjectSample/images/LoginBox.png'); background-repeat: no-repeat;"> Is there something incorrect with the way this style tag is referencing an image with ...

The JSON is not displaying in the expected sequence

I am currently working with a json file named places.json which contains data on various cities around the world. Here is a snippet of the file: { "Europe": [ { "name": "London", "country": "England" }, ...

Display a dynamic image within a single window with real-time updates

Is there a way to display a jpg in a window that updates multiple times per second without adding another 100 lines of code? I have developed a very compact program consisting of only 100 lines (a neural network generating the image), and I'm looking ...

Ways to decrease the space between lines of text within a single mat-option element

https://i.sstatic.net/Sr1cb.png ::ng-deep .mat-select-panel mat-option.mat-option { height: unset; } ::ng-deep .mat-option-text.mat-option-text { white-space: normal; } Currently, I have implemented this code to ensure that text in options wraps to t ...

Is there a way to update a PHP include file without needing to refresh the page?

I've been learning as I go, so some of my questions may seem basic or beyond my current knowledge level. However, I find that peer explanations, examples, and advice are the most effective way for me to learn. Thank you in advance for your help. Usin ...

Is there a way to consistently maintain a specific column size in Bootstrap?

I'm currently working on a website and running into an issue that I can't seem to resolve. The problem lies in the layout of multiple cards with information; they are arranged in columns and when there are more than 4 columns, they switch to a ne ...