Responsive Modal
How do I make an responsive modal?
What is a responsive modal? How do you make a responsive modal? This script and codes were developed by Daniel Grant on 28 December 2022, Wednesday.
Responsive Modal - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Responsive Modal</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ * { position: relative; box-sizing: border-box;
}
html, body { height: 100%; overflow: hidden;
}
.cf:before, .Modal-header:before,
.cf:after,
.Modal-header:after { content: " "; display: table;
}
.cf:after, .Modal-header:after { clear: both;
}
.Modal { position: absolute; width: 100%; height: 100%; z-index: 100; background: #fff; backface-visibility: hidden;
}
.Modal-header { background: #fff; border-bottom: 1px solid #ccc;
}
.Modal-header h3 { position: absolute; width: 100%; line-height: 32px; text-align: center;
}
.Modal-body { height: 100%; background: #eee;
}
.Modal-footer { border-top: 1px solid #ccc;
}
@media screen and (max-width: 599px) { .tablet { display: none; } .Modal { transition: transform 0.35s linear; transform: translateY(200%); } .Modal.is-open { transform: translateY(0%); }
}
@media screen and (min-width: 600px) { .mobile { display: none; } .tablet { display: block; } .Modal { position: absolute; left: 50%; top: 50%; transform: translate(-50%, 75%); opacity: 0; width: 500px; height: auto; } .Modal.is-open { transform: translate(-50%, -50%); box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.7); opacity: 1; transition: transform 0.2s linear 0.2s, opacity 0.4s linear; } .Modal.is-closed { opacity: 0; transition: opacity 1s linear, transform 0.2s linear; } .Modal-header h3 { position: relative; } .Modal-body { height: 250px; }
}
h1, h2, h3 { line-height: 1; margin: 0;
}
button { padding: 0 8px; border: none; border-radius: 3px; background: #ccc; color: #444; transition: 0.1s; height: 30px; line-height: 30px;
}
button:active { background: #ddd; box-shadow: inset 1px 2px rgba(0, 0, 0, 0.1);
}
.gutter { padding: 12px;
}
.muted { color: #999;
}
.pull-left { float: left;
}
.pull-right { float: right;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div class="Modal is-closed" id="modal"> <div class="Modal-header gutter mobile"> <h3>Send Email</h3> <button data-hook="button-cancel" class="pull-left">Cancel</button> <button data-hook="button-send" class="pull-right">Send</button> </div> <div class="Modal-header gutter tablet"> <h3>Send Email</h3> </div> <div class="Modal-body gutter"> <p class="muted">Start typing...</p> </div> <div class="Modal-footer gutter tablet"> <button data-hook="button-cancel">Cancel</button> <button data-hook="button-send" class="pull-right">Send</button> </div>
</div>
<div class="gutter"> <button data-hook="button-open">Compose</button>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Responsive Modal - Script Codes CSS Codes
* { position: relative; box-sizing: border-box;
}
html, body { height: 100%; overflow: hidden;
}
.cf:before, .Modal-header:before,
.cf:after,
.Modal-header:after { content: " "; display: table;
}
.cf:after, .Modal-header:after { clear: both;
}
.Modal { position: absolute; width: 100%; height: 100%; z-index: 100; background: #fff; backface-visibility: hidden;
}
.Modal-header { background: #fff; border-bottom: 1px solid #ccc;
}
.Modal-header h3 { position: absolute; width: 100%; line-height: 32px; text-align: center;
}
.Modal-body { height: 100%; background: #eee;
}
.Modal-footer { border-top: 1px solid #ccc;
}
@media screen and (max-width: 599px) { .tablet { display: none; } .Modal { transition: transform 0.35s linear; transform: translateY(200%); } .Modal.is-open { transform: translateY(0%); }
}
@media screen and (min-width: 600px) { .mobile { display: none; } .tablet { display: block; } .Modal { position: absolute; left: 50%; top: 50%; transform: translate(-50%, 75%); opacity: 0; width: 500px; height: auto; } .Modal.is-open { transform: translate(-50%, -50%); box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.7); opacity: 1; transition: transform 0.2s linear 0.2s, opacity 0.4s linear; } .Modal.is-closed { opacity: 0; transition: opacity 1s linear, transform 0.2s linear; } .Modal-header h3 { position: relative; } .Modal-body { height: 250px; }
}
h1, h2, h3 { line-height: 1; margin: 0;
}
button { padding: 0 8px; border: none; border-radius: 3px; background: #ccc; color: #444; transition: 0.1s; height: 30px; line-height: 30px;
}
button:active { background: #ddd; box-shadow: inset 1px 2px rgba(0, 0, 0, 0.1);
}
.gutter { padding: 12px;
}
.muted { color: #999;
}
.pull-left { float: left;
}
.pull-right { float: right;
}
Responsive Modal - Script Codes JS Codes
$btns = $("[data-hook='button-open'], [data-hook='button-cancel'], [data-hook='button-send']");
$modal = $('#modal');
$btns.on('click', function() { $modal.toggleClass('is-open').toggleClass('is-closed');
});
![Responsive Modal - Script Codes](http://shots.codepen.io/djgrant/pen/vskpG-512.jpg)
Developer | Daniel Grant |
Username | djgrant |
Uploaded | December 28, 2022 |
Rating | 3 |
Size | 4,178 Kb |
Views | 6,072 |
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 |
Auto expanding input addons | 3,140 Kb |
Facebook Paper Theme | 4,905 Kb |
Zero element inline validation bubble | 4,117 Kb |
A Pen by Daniel Grant | 2,464 Kb |
Responsive Modal | 4,178 Kb |
Grid crosshairs | 2,193 Kb |
Loading bar for ajax pages | 2,464 Kb |
Gradient Border | 2,600 Kb |
Wireframe Planet | 5,744 Kb |
Wireframe solar system | 4,856 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 |
Savemedia1.1 | EdsonAlcala | 2,148 Kb |
Funny menu | AxeLVaisper | 4,671 Kb |
Simple Flat Menu | Jeplaa | 2,467 Kb |
3D Text in Sass | Bookcasey | 2,766 Kb |
Em Test | Rodesco | 1,784 Kb |
Find The Penguin | Lelder | 2,212 Kb |
Placeholder support for contentEditable elements, without JavaScript | Flesler | 1,863 Kb |
Responsive Table-less Shopping Cart | Alex_rodrigues | 6,637 Kb |
A Pen by Paul Sullivan | Pwsm50 | 2,349 Kb |
GrcJS | Vino6 | 2,047 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!