Simple Popup Window using HTML and CSS

In this tutorial, you will learn how to create a popup window using HTML CSS only. A pop-up window is a common web element that is used by many websites. 

The HTML popup window is used primarily to display e-mail subscription forms, login forms, or any other advertisements. 


Popup Window using HTML and CSS

Earlier I created an automatic popup window using JavaScript. However, this design is not automatic. This popup needs to be opened manually. Only HTML and CSS are used here. There are many beginners who want to create popup boxes without JavaScript, this design is for them.

I have shown many types of elements using popup boxes before. It is a basic structure that is completely empty. You can add elements according to your needs in that space.

How to Create Popup Window using HTML CSS

HTML checkbox has been used to execute the HTML popup box. A small button has been created on the webpage. This popup box will be completely hidden under normal conditions. The window will be visible when you click on the button. 

This popup window HTML contains a small cancel button. When you click on that button, the window disappears again.


See the Pen Untitled by Shantanu Jana (@shantanu-jana) on CodePen.


Below I have given all the source codes to make it and show you how to use these codes. Although there is a button at the bottom of the article that allows you to download all the code to create this simple popup window.



Popup Window HTML Code

The code below is the HTML code that added all the information to this project. Copy these codes and add them to your HTML file. This is where a popup button was first created. A box is then created and a cross mark is used in this box.


<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
  <!--CSS file-->
  <link rel="stylesheet" href="style.css">
</head>

<body>
   
<div class="center">
  <input type="checkbox" id="click">
  <label for="click" class="click-me">Login Form</label>

  <div class="content">
   <label for="click" id="times">x</label>
  </div>
</div>

</body>
</html>


Design Popup Window by CSS

Now it's time to design this popup box with CSS. Copy the following code and add it to your CSS file. You can add all these codes to the HTML file if you want. To do this, you must rename your CSS file using style.css.


body{
  margin:0;
  padding:0;
  font-family:sans-serif;
  background: linear-gradient(
          135deg,
          #083760 50%,
          #1b72b2 50%
      );
  min-height: 100vh;
}

.center,.content{
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%,-50%);
}

.click-me{
  display:block;
  font-size:22px;
  line-height:50px;
  cursor:pointer;
  width:160px;
  height:50px;
  background: #fff;
  text-align:center;
}

#click{
  display:none;
}
.click-me:hover{
  color: #08adef;
  box-shadow: 0px 0px 7px #babecc;
}

.content{
  opacity:0;
  visibility:hidden;
  width: 360px;
  min-height: 300px;
  box-sizing: border-box;
  padding: 30px 35px 40px;
  padding-right: 40px;
  height: auto;
  background: #fff;
 }

#times{
  position:absolute;
  right:10px;
  top:20px;
  font-size:25px;
  padding-left: 11px;
  padding-right: 11px;
  border-radius: 50%;
  cursor:pointer;
  background: #013786;
  padding: 3px;
  color: white;
}

#click:checked~.content{
  opacity:1;
  visibility:visible;
}

Hopefully, you can create a simple HTML CSS popup window above. If you have trouble copying the code, you can use the download button below. 

In the meantime, I have shown many types of elements such as a popup login form, and a popup email subscribes form.







Comments

Popular posts from this blog

Simple Day Night Toggle Button Using HTML and CSS

Splash Image Mask Using HTML and CSS (Free Code)

Simple RGB Color Generator Using JavaScript & CSS