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');
});
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 |
Wireframe Planet | 5,744 Kb |
Number input with controls | 2,867 Kb |
Zero element inline validation bubble | 4,117 Kb |
Wireframe solar system | 4,856 Kb |
Grid crosshairs | 2,193 Kb |
Transitioning application screens with semantically named classes | 3,697 Kb |
Responsive Tabs | 3,473 Kb |
A Pen by Daniel Grant | 2,464 Kb |
Auto expanding input addons | 3,140 Kb |
CSS triangles with border | 3,146 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 |
Mario | Takaneichinose | 3,902 Kb |
The Monty Hall Problem | Melatonind | 4,360 Kb |
Example SVGZ Data URI | Joeyhoer | 2,981 Kb |
Pure CSS Read More Arrow | Zephyr | 1,747 Kb |
Simple jQuery Slider | Jurbank | 2,874 Kb |
Swiftype Lower Third | Zumwalt | 4,796 Kb |
Elephants Full screen site | Orrinward | 3,981 Kb |
A Pen by Michael Parenteau | Michaelparenteau | 2,133 Kb |
A cube | KyleDavidE | 18,627 Kb |
Use the Twitchtv JSON API | Roksanaop | 3,561 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!