Skip to content

Instantly share code, notes, and snippets.

Created December 29, 2016 16:00
Show Gist options
  • Save anonymous/9ff3c8100e44d6fc9e8ea706e9b18e83 to your computer and use it in GitHub Desktop.
Save anonymous/9ff3c8100e44d6fc9e8ea706e9b18e83 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/licolajowu
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
* {
box-sizing: border-box;
}
.dropdown {
cursor: pointer;
position: relative;
display: inline-block;
outline: none;
text-align: left;
line-height: 1em;
padding: 18px 0 22px 18px;
background: #fff;
min-width: 14em;
border: 1px solid rgba(34, 36, 38, 0.15);
border-radius: 29px;
}
.dropdown .text {
user-select: none;
-webkit-user-select: none;
}
.dropdown .menu {
margin: 0em;
padding: 0em 0em;
cursor: auto;
position: absolute;
display: none;
outline: none;
top: 100%;
left: 0;
width: auto;
min-width: calc(100% + 2px);
width: calc(100% + 2px);
margin: 0px -1px;
background: #fff;
border: 1px solid rgba(34, 36, 38, 0.15);
border-top-width: 0px !important;
border-radius: 0em 0em 29px 29px;
box-shadow: 0px 2px 3px 0px rgba(34, 36, 38, 0.15);
border-color: #96C8DA
}
.dropdown .menu > .item {
position: relative;
cursor: pointer;
display: block;
border: none;
line-height: 1em;
font-size: 1rem;
padding: 0.78571429rem 1.14285714rem !important;
}
.dropdown.active {
border-color: #96C8DA
}
.dropdown.active .menu {
display: initial;
z-index: 10;
}
.dropdown:not(.active):hover {
border-color: rgba(34, 36, 38, 0.35);
box-shadow: none;
}
.dropdown.active {
border-bottom-left-radius: 0em !important;
border-bottom-right-radius: 0em !important;
}
</style>
</head>
<body>
<div class="dropdown">
<i class="icon"></i>
<div class="text">Please select</div>
<div class="menu">
<div class="item">
On
</div>
<div class="item">
Off
</div>
</div>
</div>
<div class="dropdown">
<i class="icon"></i>
<div class="text">Please select</div>
<div class="menu">
<div class="item">
On
</div>
<div class="item">
Off
</div>
</div>
</div>
<script id="jsbin-javascript">
Array
.from(document.querySelectorAll('.dropdown'))
.forEach(d =>
d.addEventListener('click', (e) => {
e.target
.closest('.dropdown')
.classList
.toggle('active');
})
)
</script>
<script id="jsbin-source-css" type="text/css">* {
box-sizing: border-box;
}
.dropdown {
cursor: pointer;
position: relative;
display: inline-block;
outline: none;
text-align: left;
line-height: 1em;
padding: 18px 0 22px 18px;
background: #fff;
min-width: 14em;
border: 1px solid rgba(34, 36, 38, 0.15);
border-radius: 29px;
}
.dropdown .text {
user-select: none;
-webkit-user-select: none;
}
.dropdown .menu {
margin: 0em;
padding: 0em 0em;
cursor: auto;
position: absolute;
display: none;
outline: none;
top: 100%;
left: 0;
width: auto;
min-width: calc(100% + 2px);
width: calc(100% + 2px);
margin: 0px -1px;
background: #fff;
border: 1px solid rgba(34, 36, 38, 0.15);
border-top-width: 0px !important;
border-radius: 0em 0em 29px 29px;
box-shadow: 0px 2px 3px 0px rgba(34, 36, 38, 0.15);
border-color: #96C8DA
}
.dropdown .menu > .item {
position: relative;
cursor: pointer;
display: block;
border: none;
line-height: 1em;
font-size: 1rem;
padding: 0.78571429rem 1.14285714rem !important;
}
.dropdown.active {
border-color: #96C8DA
}
.dropdown.active .menu {
display: initial;
z-index: 10;
}
.dropdown:not(.active):hover {
border-color: rgba(34, 36, 38, 0.35);
box-shadow: none;
}
.dropdown.active {
border-bottom-left-radius: 0em !important;
border-bottom-right-radius: 0em !important;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">Array
.from(document.querySelectorAll('.dropdown'))
.forEach(d =>
d.addEventListener('click', (e) => {
e.target
.closest('.dropdown')
.classList
.toggle('active');
})
)</script></body>
</html>
* {
box-sizing: border-box;
}
.dropdown {
cursor: pointer;
position: relative;
display: inline-block;
outline: none;
text-align: left;
line-height: 1em;
padding: 18px 0 22px 18px;
background: #fff;
min-width: 14em;
border: 1px solid rgba(34, 36, 38, 0.15);
border-radius: 29px;
}
.dropdown .text {
user-select: none;
-webkit-user-select: none;
}
.dropdown .menu {
margin: 0em;
padding: 0em 0em;
cursor: auto;
position: absolute;
display: none;
outline: none;
top: 100%;
left: 0;
width: auto;
min-width: calc(100% + 2px);
width: calc(100% + 2px);
margin: 0px -1px;
background: #fff;
border: 1px solid rgba(34, 36, 38, 0.15);
border-top-width: 0px !important;
border-radius: 0em 0em 29px 29px;
box-shadow: 0px 2px 3px 0px rgba(34, 36, 38, 0.15);
border-color: #96C8DA
}
.dropdown .menu > .item {
position: relative;
cursor: pointer;
display: block;
border: none;
line-height: 1em;
font-size: 1rem;
padding: 0.78571429rem 1.14285714rem !important;
}
.dropdown.active {
border-color: #96C8DA
}
.dropdown.active .menu {
display: initial;
z-index: 10;
}
.dropdown:not(.active):hover {
border-color: rgba(34, 36, 38, 0.35);
box-shadow: none;
}
.dropdown.active {
border-bottom-left-radius: 0em !important;
border-bottom-right-radius: 0em !important;
}
Array
.from(document.querySelectorAll('.dropdown'))
.forEach(d =>
d.addEventListener('click', (e) => {
e.target
.closest('.dropdown')
.classList
.toggle('active');
})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment