Create Modal Box Using CSS And JS


How to create Modal Box with CSS and JavaScript. The purpose is to complete a transparent and simple modal popup box that does not use third-party libraries and is cross-browser compatible. We have to use vanilla JavaScript. Since we have been creating it from the start, we have complete control over how it looks and works.

Create Modal Box Using CSS and JS

Modal popups are widely used on the web. Some of their popular uses include driving newsletter signups, displaying notifications/alerts, and handling registration forms.

This model will be broad which means you’ll be free to use it for any purpose and anywhere.

HTML

Let’s start with HTML code.


<div class="container"> <div class="popup-box"> <a class="close-button popup-close" title="close">×</a> <h2>This is My PopUp</h2> <h3>How to create a model box with HTML CSS and JavaScript.</h3> </div> </div> <a class="button popup-button">Open Model!</a>

CSS Code:


<style> body { font-family: "Open Sans"; line-height: 200%; } .container { position: fixed; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 1.5); opacity: 0; visibility: hidden; transform: scale(1.1); transition: visibility 0s linear 0.25s, opacity 0.25s 0s, transform 0.25s; } h2, h3{ text-align:center; font-size: 5.5em; padding:20px;} h3{ text-align:center; font-size: 4em; line-height:1.5em; color:#888;} .button { padding: 2.2% 5.5%; display: inline-block; -webkit-transition: all linear 0.15s; transition: all linear 0.15s; border-radius: 3px; background: #7b78ff; font-size: 22px; font-weight: bold; text-decoration: none; text-transform: uppercase; color: #fff;} .button:hover { opacity: 1.75; cursor:pointer; color:#000;} .popup-box { width: 80%; height:500px; padding: 70px; transform: translate(-50%, -50%) scale(0.5); position: absolute; top: 50%; left: 50%; box-shadow: 0px 2px 16px rgba(0, 0, 0, 0.8); border-radius: 5px; background: #fff; text-align: center;} .close-button { width: 35px; height: 35px; display: inline-block; position: absolute; top: 10px; font-size:60px; right: 10px; -webkit-transition: all ease 0.5s; transition: all ease 0.5s; border-radius: 50%; background: #7b78ff; font-weight: bold; color: #fff; text-align:center; cursor:pointer; } .close-button:hover { -webkit-transform: rotate(180deg); transform: rotate(400deg); } .show-container { opacity: 1; visibility: visible; transform: scale(1.0); transition: visibility 0s linear 0s, opacity 1.25s 0s, transform 1.25s; } </style>

Create Modal Box Using CSS And JS

Cards you may also be interested in
10X Profit Bots System Review – $5000 Bonuses, Discount, OTO Details
tikareview
4
0
0
Australia Study Visa With Spouse Free Assessment With Career Guidance
Netwalks123
2
0
0
Video
READDOWNLOAD%# Visualization Analysis &amp; Design Ebooks download by Tamara Munzner
vicidonmia
0
0
0
Convert Website To CMS In Great Budget!
hirewpgeeks
0
0
0
WPThemePlugin BlackFriday 2022 Deal – 3-in-1 Amazon + eBay WP Tools Bundle
monopolyin
1
0
0
Jasa Cargo Jakarta ke Saumlaki (0816267079)
bandungexpress
5
1
0
{epub download} Illustrated Microsoft Office 365 &amp; Excel 2019 Comprehensive [K I N D L E] by Elizabeth Eisner Reding
vicidonmia
0
0
0
Saigrace International Boarding School in Dehradun, India
saigrace
3
0
0
$READ$ EBOOK Hands-On Data Preprocessing in Python Learn how to effectively prepare data for successful data analytics (DOWNLOAD E.B.O.O.K.^) by Roy Jafari
kindleutumn
1
0
0
BLACK FRIDAY BLOWOUT (PLR)Marketing Newsletters 3-Pack From Kam Fatz
monopolyin
1
0
0
UnikBrushes is a Brand that offers a wide range of Web Solutions for your unique Businesses.
Ash2580
1
0
0
Joymart | Thế giới đèn trang trí nội thất phòng khách giá rẻ số 1 Hà Nội
joymart208
1
0
0
NFT game Discord Marketing Agency
tenzval1026
1
0
0
Why is Caribbean Medical School?
asinfovision
2
1
0
Công nghệ in UV mang lại ứng dụng gì trong đời sống?
lanhdt1987
3
0
0
Full Pages Technology for Success and Illustrated Series(tm) Microsoft Office 365 &amp; Office 2019 [Best!] by June Jamrich Parsons
garrynnono
0
0
0
Boost Your Convert Your Site To WordPress With HireWPGeeks
hirewpgeeks
0
0
0
[Best!] Coding with Roblox Lua in 24 Hours The Official Roblox Guide Full Books by Roblox Corporation
garrynnono
0
0
0
MegaSuite Black Friday Special – Done For You Marketplace With Sellable Stock Assets
monopolyin
1
0
0
Time for marketers to re-think
digitalshukla
6
0
1
4.7 Star App Store Review!
Cpl.dev***uke
The Communities are great you rarely see anyone get in to an argument :)
king***ing
Love Love LOVE
Download

Select Collections