Pure CSS Pop Up Modal

Developer
Size
2,858 Kb
Views
12,144

How do I make an pure css pop up modal?

A modal pop up that doesn't require any JS to function - simply CSS with a few advanced selectors.. What is a pure css pop up modal? How do you make a pure css pop up modal? This script and codes were developed by James Zedd on 11 October 2022, Tuesday.

Pure CSS Pop Up Modal Previews

Pure CSS Pop Up Modal - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Pure CSS Pop Up Modal</title> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="container"> <div class="site-title"> <h1>Elite World Explorer</h1> </div> <div class="content"> <h1>5 Best Desinations in the World</h1> <img src="https://placehold.it/700x250" alt="" class="" /> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse eget nulla mollis, efficitur urna nec, viverra dolor. Nulla facilisi. Interdum et malesuada fames ac ante ipsum primis in faucibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Praesent efficitur finibus eros sit amet sagittis. Ut sollicitudin sodales neque et volutpat. Curabitur dictum ante vel fermentum volutpat. Curabitur ac neque et erat viverra egestas.</p> <label for="showModal" class="modal-show">Show Modal</label> <input type="checkbox" id="showModal" /> <div class="overlay"></div> <div class="modal-box"> <label for="showModal" class="modal-close"><i class="fa fa-times"></i></label> <h2>Sign up for our mailing list</h2> <input type="text" placeholder="First Name" /> <input type="text" placeholder="Email Address" /> <button type="submit">Submit</button> </div> </div>
</div> <script src="js/index.js"></script>
</body>
</html>

Pure CSS Pop Up Modal - Script Codes CSS Codes

body { position: relative;
}
.container { padding: 20px; font-family: 'Lato', arial, sans-serif; max-width: 700px; margin: 0 auto; z-index: 0;
}
.site-title { text-align: center; border-bottom: 1px solid #111111; margin-bottom: 24px;
}
.site-title h1 { font-weight: 300; text-transform: uppercase; letter-spacing: 10px;
}
img { width: 100%;
}
.content p { line-height: 1.6em; margin-bottom: 24px;
}
label { cursor: pointer; transition: all 300ms ease-in-out;
}
label.modal-show { padding: 12px 18px; border-radius: 12px; background: #31b0d5; color: #ffffff;
}
label.modal-show:hover { background: #269abc;
}
label.modal-close { position: absolute; top: -25px; right: -25px; font-size: 24px; color: rgba(255,0,0,0.6);
}
label.modal-close:hover { color: rgba(255,0,0,0.9);
}
#showModal { display: none;
}
.overlay { display: block; posItion: fixed; top: 0; left: 0; z-index: 1; width: 0; height: 0; background: rgba(0,0,0,0); transition: background 1s ease-in-out;
}
.modal-box { position: absolute; top: -500px; left: 50%; margin-right: -50%; transform: translate(-50%,-50%); z-index: 2; border-radius: 12px; padding: 24px 18px; background: #f1f1f1; transition: all 300ms linear;
}
.modal-box h2 { margin-top: 0;
}
.modal-box input { display: block; width: 100%; margin-bottom: 12px; text-indent: 4px; padding: 4px 0; border-radius: 4px; border: 2px solid #ffffff; box-sizing : border-box;
}
.modal-box button { display: block; margin: 0 auto;
}
/*-- The Magic --*/
#showModal:checked ~ .modal-box { top: 50%;
}
#showModal:checked ~ .overlay { width: 100%; height: 100%; background: rgba(0,0,0,0.7);
}
/* -- */
@media (max-width: 479px) { .modal-box { max-width: 200px; } .modal-box input { width: initial; } label.modal-close { right: -15px; }
}

Pure CSS Pop Up Modal - Script Codes JS Codes

// nothing to see here :P
Pure CSS Pop Up Modal - Script Codes
Pure CSS Pop Up Modal - Script Codes
Home Page Home
Developer James Zedd
Username james_zedd
Uploaded October 11, 2022
Rating 3
Size 2,858 Kb
Views 12,144
Do you need developer help for Pure CSS Pop Up Modal?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

James Zedd (james_zedd) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!