Custom Dropdown
How do I make an custom dropdown?
Part of my Responsive Menu Concepts article on CSS-Tricks.. What is a custom dropdown? How do you make a custom dropdown? This script and codes were developed by Tim Pietrusky on 20 June 2022, Monday.
Custom Dropdown - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Custom Dropdown</title> <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! */ * { box-sizing: border-box;
}
html,
body { width: 100%; height: 100%;
}
body { margin: .75em; background: url(http://cache.clickonf5.org/wp-content/uploads/2010/04/ubuntu_wallpaper_thumb.png); background-size: cover;
}
/* Advanced Checkbox Hack */
body { -webkit-animation: bugfix infinite 1s;
}
@-webkit-keyframes bugfix { from { padding: 0; } to { padding: 0; }
}
input[type=checkbox] { position: absolute; top: -9999px; left: -9999px;
}
label { display: none; cursor: pointer; user-select: none;
}
/* background for li / select */
/* custom-dropdown */
nav[role="custom-dropdown"] { position: relative; width: 100%;
}
nav[role="custom-dropdown"] a,
nav[role="custom-dropdown"] label { color: #ccc; text-decoration: none; font: 1.4em sans-serif; transition: color .3s ease-in-out;
}
nav[role="custom-dropdown"] ul { padding: 0; margin: 0 auto; width: 100%; list-style: none;
}
nav[role="custom-dropdown"] ul > li { float: left; padding: .55em .55em; width: 19%; background-image: url(https://raw.github.com/TimPietrusky/mantisbt-is-a-rockstar/master/rockstar/img/bg_dark_grey.png); text-align: center; transition-duration: .3s; transition-timing-function: ease-in-out; transition-property: box-shadow, color; box-shadow: 0 0.05em 0.25em 0 rgba(0, 0, 0, 0.35); cursor: pointer;
}
nav[role="custom-dropdown"] ul > li:hover { background-color: rgba(0, 0, 0, 0.85); color: #fff; box-shadow: 0 0.05em 0.25em 0 rgba(0, 0, 0, 0.35), inset 0 0 0 2em rgba(0, 0, 0, 0.3);
}
nav[role="custom-dropdown"] ul > li:hover > a { color: #fff;
}
/* small screens */
@media screen and (max-width: 44em) { html, body { margin: 0; } nav[role="custom-dropdown"] ul { display: none; height: 100%; } nav[role="custom-dropdown"] label { position: relative; display: block; width: 100%; min-height: 2.25em; padding: .45em; font-size: 1.1em; margin: 0; border: 0.15em solid rgba(60, 60, 60, 0.2); background-image: url(https://raw.github.com/TimPietrusky/mantisbt-is-a-rockstar/master/rockstar/img/bg_dark_grey.png); } nav[role="custom-dropdown"] label:after { position: absolute; right: .25em; top: 0; content: "\2261"; font-size: 1.8em; } nav[role="custom-dropdown"] input[type=checkbox]:checked ~ label:after { color: #222; } nav[role="custom-dropdown"] input[type=checkbox]:checked ~ ul { display: block; } nav[role="custom-dropdown"] input[type=checkbox]:checked ~ ul > li { width: 100%; opacity: .8; text-align: left; } nav[role="custom-dropdown"] input[type=checkbox]:checked ~ ul > li:after { position: absolute; right: .25em; content: "\203A"; font: bold 1.4em sans-serif; }
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <nav role="custom-dropdown"> <input type="checkbox" id="button"> <label for="button" onclick></label> <ul> <li><a href="#">Stream</a></li> <li><a href="#">Lab</a></li> <li><a href="#">Projects</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul>
</nav> <script src="js/index.js"></script>
</body>
</html>
Custom Dropdown - Script Codes CSS Codes
* { box-sizing: border-box;
}
html,
body { width: 100%; height: 100%;
}
body { margin: .75em; background: url(http://cache.clickonf5.org/wp-content/uploads/2010/04/ubuntu_wallpaper_thumb.png); background-size: cover;
}
/* Advanced Checkbox Hack */
body { -webkit-animation: bugfix infinite 1s;
}
@-webkit-keyframes bugfix { from { padding: 0; } to { padding: 0; }
}
input[type=checkbox] { position: absolute; top: -9999px; left: -9999px;
}
label { display: none; cursor: pointer; user-select: none;
}
/* background for li / select */
/* custom-dropdown */
nav[role="custom-dropdown"] { position: relative; width: 100%;
}
nav[role="custom-dropdown"] a,
nav[role="custom-dropdown"] label { color: #ccc; text-decoration: none; font: 1.4em sans-serif; transition: color .3s ease-in-out;
}
nav[role="custom-dropdown"] ul { padding: 0; margin: 0 auto; width: 100%; list-style: none;
}
nav[role="custom-dropdown"] ul > li { float: left; padding: .55em .55em; width: 19%; background-image: url(https://raw.github.com/TimPietrusky/mantisbt-is-a-rockstar/master/rockstar/img/bg_dark_grey.png); text-align: center; transition-duration: .3s; transition-timing-function: ease-in-out; transition-property: box-shadow, color; box-shadow: 0 0.05em 0.25em 0 rgba(0, 0, 0, 0.35); cursor: pointer;
}
nav[role="custom-dropdown"] ul > li:hover { background-color: rgba(0, 0, 0, 0.85); color: #fff; box-shadow: 0 0.05em 0.25em 0 rgba(0, 0, 0, 0.35), inset 0 0 0 2em rgba(0, 0, 0, 0.3);
}
nav[role="custom-dropdown"] ul > li:hover > a { color: #fff;
}
/* small screens */
@media screen and (max-width: 44em) { html, body { margin: 0; } nav[role="custom-dropdown"] ul { display: none; height: 100%; } nav[role="custom-dropdown"] label { position: relative; display: block; width: 100%; min-height: 2.25em; padding: .45em; font-size: 1.1em; margin: 0; border: 0.15em solid rgba(60, 60, 60, 0.2); background-image: url(https://raw.github.com/TimPietrusky/mantisbt-is-a-rockstar/master/rockstar/img/bg_dark_grey.png); } nav[role="custom-dropdown"] label:after { position: absolute; right: .25em; top: 0; content: "\2261"; font-size: 1.8em; } nav[role="custom-dropdown"] input[type=checkbox]:checked ~ label:after { color: #222; } nav[role="custom-dropdown"] input[type=checkbox]:checked ~ ul { display: block; } nav[role="custom-dropdown"] input[type=checkbox]:checked ~ ul > li { width: 100%; opacity: .8; text-align: left; } nav[role="custom-dropdown"] input[type=checkbox]:checked ~ ul > li:after { position: absolute; right: .25em; content: "\203A"; font: bold 1.4em sans-serif; }
}
Custom Dropdown - Script Codes JS Codes
/** Custom Dropdown # What? # Part of my "Responsive Menu Concepts" article on CSS-Tricks http://css-tricks.com/responsive-menu-concepts # 2012 by Tim Pietrusky # timpietrusky.com
**/
Developer | Tim Pietrusky |
Username | TimPietrusky |
Uploaded | June 20, 2022 |
Rating | 4.5 |
Size | 4,878 Kb |
Views | 44,528 |
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 |
ID Card - Skills | 5,680 Kb |
Monster Energy SVG logo animated | 7,705 Kb |
Icon Fonts - CSS-Loader | 2,940 Kb |
Gravatar URL Generator | 5,813 Kb |
Playlist UI for Rodeo 004 | 6,848 Kb |
Liquid Loading | 3,135 Kb |
SNES Controller | 8,625 Kb |
Select | 4,112 Kb |
Asdf | 16,941 Kb |
Star Wars opening crawl from 1977 | 9,093 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 |
A Pen by lizz | Lizz | 10,068 Kb |
Testimonial Fancy tabs responsive | Amit-webdesigner | 3,056 Kb |
BlueBox Fork | Huskynation | 12,675 Kb |
Count up | Alanshortis | 2,391 Kb |
No Vacancy 404 CSS Only | Sethkontny | 0 Kb |
Review test | Otro_user_gil | 4,054 Kb |
Pure CSS Torch Light | Juliendargelos | 2,727 Kb |
Simple Carousel Pure CSS | Dangvanthanh | 4,080 Kb |
Fireworks Show | Arianalynn | 3,048 Kb |
Basic HTML Slideshow | Tomhodgins | 3,386 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!