What is the code for Pop up?

For my one of the website , i want to design a sign up pop in CSS. How can i do it?

The following code is not working

<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Sign Up Pop-up</title>
    .popup {display:none;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);border:1px solid #ccc;padding:20px;background-color:#fff;box-shadow:0 0 10px rgba(0,0,0,0.1);z-index:9999;}
    .close {position:absolute;top:10px;right:10px;cursor:pointer;}
    .overlay {display:none;position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,0.5);z-index:999;}

<button onclick="document.getElementById('popup').style.display='block';document.getElementById('overlay').style.display='block'">Sign Up</button>

<div class="popup" id="popup">
  <span class="close" onclick="document.getElementById('popup').style.display='none';document.getElementById('overlay').style.display='none'">&times;</span>
  <h2>Sign Up</h2>
    <input type="email" name="email"><br>
    <input type="password" name="password"><br><br>
    <input type="submit" value="Submit">

<div class="overlay" id="overlay"></div>


@onlineexam when you post code, you need to format it for the forums. Just put three backticks ``` on a separate line before and after your code. I have done it for you this time.

Define not working. For me, when I click on the button, I see a popup.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.