CSS-Centered Modal Window
How do I make an css-centered modal window?
This code-pen shows a centered modal window using only css. The centering remains as the window is resized. The modal window can have any dimension. For this pen, it has a min-height and specified width but you can also the height and width without affecting the centering. The close button is also centered and anchored to the bottom of the modal window.. What is a css-centered modal window? How do you make a css-centered modal window? This script and codes were developed by Retrofuturistic on 19 January 2023, Thursday.
CSS-Centered Modal Window - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>CSS-Centered Modal Window </title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="modalWrapper"> <div class="modal"> <div class="bg_gradient"></div> <div class="errors"> <h4>Error Message</h4> <ul class="tightList"> <li>Credit Card Expired</li> <li>Incorrect CVV</li> </ul> <div class="bigBtn"><a href="#">Close</a></div> </div> </div>
</div>
<div class="site"> <div class="bg_gradient"></div> <div class="content"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </div>
</div>
</body>
</html>
CSS-Centered Modal Window - Script Codes CSS Codes
body { padding:0; margin:0; background: #fff; /* Old browsers */
}
.modalWrapper { position: fixed; text-align: center; background: rgba(0,0,0, 0.3); top:0; left: 0; right: 0; bottom: 0; z-index: 2;
}
.modalWrapper:before { content: ''; display: inline-block; height: 100%; vertical-align: middle; margin-right: -0.25em; /* Adjusts for spacing */ /* For visualization background: #808080; width: 5px; */ }
.modal { position: relative; display: inline-block; vertical-align: middle; width: 300px; padding: 15px 15px 0px; border: #000000 solid 1px; background: #ffffff; -webkit-box-shadow: 0px 7px 5px 0px rgba(0, 0, 0, 0.7); box-shadow: 0px 7px 5px 0px rgba(0, 0, 0, 0.7); }
.modal .gradient_bg{ height: 100px }
.errors { position: relative; min-height: 150px;
}
.errors h4 { font-family:'Source Sans Pro', sans-serif; margin-bottom: 20px;
}
.errors .tightList { text-align: left; margin-bottom: 20px;
}
.errors .bigBtn { position: absolute; display: block; background: none; bottom: 0; width: 100%; padding: 0;
}
.errors .bigBtn a{ display: inline-block; background-image: none; background-color: rgb(129,23,27); padding: 5px 30px; color: #ffffff; font-size: 15px; line-height: 1.5; text-decoration:none; -webkit-box-shadow: 0px 5px 15px -1px rgba(70, 70, 70, 0.6); box-shadow: 0px 5px 15px -1px rgba(70, 70, 70, 0.6);
}
.site { padding:0; margin:0; margin-top:-17px; position:relative;
}
.bg_gradient { position:absolute; top:0; left:0; width:100%; background: #fff -webkit-linear-gradient(top, rgb(212,205,182) 0%,rgb(255,255,255) 100%); /* W3C */ height:100px;
}
.content { position:relative; padding:30px;
}
![CSS-Centered Modal Window - Script Codes](http://shots.codepen.io/retrofuturistic/pen/ygCpa-512.jpg)
Developer | Retrofuturistic |
Username | retrofuturistic |
Uploaded | January 19, 2023 |
Rating | 3 |
Size | 2,618 Kb |
Views | 4,048 |
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!
Name | Size |
Country List with Pagination | 2,437 Kb |
Responsive Skew | 2,351 Kb |
Expandable Left Side Bar with jQuery animate | 2,483 Kb |
Responsive Horizontally Centered Cards | 2,451 Kb |
Slide Toggle Menu | 1,772 Kb |
Responsive Cards Layout | 2,444 Kb |
A Pen by retrofuturistic | 1,605 Kb |
Box Shadow Effects | 2,143 Kb |
Nonresponsive Cards | 1,739 Kb |
Responsive Skewed Text with Images | 2,197 Kb |
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!
Name | Username | Size |
Css3 slide | Nakome | 3,190 Kb |
Pure CSS Torch Light | Juliendargelos | 2,727 Kb |
Tab Menus | Zephyr | 3,180 Kb |
Animated css matrix type | NielsOeltjen | 3,484 Kb |
Vertical Pan Hammer.js example | Jtangelder | 2,144 Kb |
Airbnb Homepage | SindhujaD | 2,480 Kb |
Simple Weather App | Cmwebby | 0 Kb |
Simple, flat contact form | Zeaklous | 2,719 Kb |
Slider css only | Armandobau | 2,161 Kb |
Donut Chart example - MorrisJS | Capelo | 2,385 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!