Drop-down - Custom Element
How do I make an drop-down - custom element?
Bootstrap like drop-down using custom element.. What is a drop-down - custom element? How do you make a drop-down - custom element? This script and codes were developed by Shridhar Deshmukh on 22 July 2022, Friday.
Drop-down - Custom Element - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Drop-down - Custom Element</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <drop-down> <button>Web Components</button> <ul class="menu" role="menu"> <li role="presentation"><a href="#">Custom Element</a></li> <li role="presentation"><a href="#">HTML Imports</a></li> <li role="presentation"><a href="#">Shadow DOM</a></li> <li role="presentation"><a href="#">HTML Templates</a></li> </ul>
</drop-down> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Drop-down - Custom Element - Script Codes CSS Codes
body { margin: 15px;
}
drop-down:unresolved { display: none;
}
drop-down { position: relative; display: inline-block;
}
drop-down button { background-color: #FFF; padding: 5px 15px; color: #333; border: 1px solid #CCC; border-radius: 5px; outline: none;
}
drop-down .menu { list-style: none; padding: 5px 0; border: 1px solid #CCC; border-radius: 5px; float: left; min-width: 100%; position: absolute; top: 100%; margin: 0px;
}
drop-down .menu a { display: block; padding: 3px 15px; clear: both; line-height: 1.3; color: #333; text-decoration: none;
}
drop-down .menu a:hover { text-decoration: none; color: #262626; background-color: #EEE;
}
drop-down button:after { content: ""; display: inline-block; width: 0; height: 0; margin-left: 5px; vertical-align: middle; border-top: 4px solid; border-right: 4px solid transparent; border-left: 4px solid transparent;
}
Drop-down - Custom Element - Script Codes JS Codes
var dropDownProto = Object.create(HTMLElement.prototype);
dropDownProto.createdCallback = function() { var button = this.querySelector("button"); var menu = this.querySelector(".menu"); button.addEventListener("click", function() { if(menu.style.display == 'none') menu.style.display = 'block'; else menu.style.display = 'none'; });
}
var DropDown = document.registerElement("drop-down", {prototype: dropDownProto});
Developer | Shridhar Deshmukh |
Username | _shree33 |
Uploaded | July 22, 2022 |
Rating | 3 |
Size | 2,285 Kb |
Views | 54,648 |
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 |
Blog Theme | 4,646 Kb |
Registration Form Desgin | 4,357 Kb |
Console logger | 1,731 Kb |
A Pen by Shridhar Deshmukh | 3,254 Kb |
Hover Message Design | 1,711 Kb |
This with bind | 1,732 Kb |
This in DOM Event Handler | 1,792 Kb |
2,706 Kb | |
HTML Imports | 1,870 Kb |
Hoisting | 2,056 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 |
SnappySnippet Test | Elmsoftware | 8,385 Kb |
Drag in vanilla js using dotval math instead of translate | Paulq | 2,662 Kb |
Z-index demo | Kblh | 1,534 Kb |
CSS3 Diamond | Rendro | 1,960 Kb |
Ionic - Wordpress REST API starter | Superpikar | 2,961 Kb |
This in constructor context | _shree33 | 1,718 Kb |
Simple Accordion | Wearebold | 3,683 Kb |
TigerWoods Freecodecamp Page | Baileytj | 2,869 Kb |
Starting out with Ember.JS | Cfleschhut | 4,808 Kb |
Flying Bee | Pwsm50 | 3,711 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!