<p>Info: <a href="https://codepen.io/miniven/pen/ZJydge" target="_blank">Pure CSS Select Box</a> A Pen By <a href="https://codepen.io/miniven" target="_blank">Veniamin</a></p>
<div class="select-box">
<div class="select-box__current" tabindex="1">
<div class="select-box__value">
<input class="select-box__input" type="radio" id="0" value="https://www.google.com" name="Ben" checked="checked">
<p class="select-box__input-text">One</p>
</div>
<div class="select-box__value">
<input class="select-box__input" type="radio" id="1" value="https://www.youtube.com" name="Ben">
<p class="select-box__input-text">Two</p>
</div>
<div class="select-box__value">
<input class="select-box__input" type="radio" id="2" value="3" name="Ben">
<p class="select-box__input-text">Three</p>
</div>
<div class="select-box__value">
<input class="select-box__input" type="radio" id="3" value="4" name="Ben">
<p class="select-box__input-text">Four</p>
</div>
<div class="select-box__value">
<input class="select-box__input" type="radio" id="4" value="5" name="Ben">
<p class="select-box__input-text">Five</p>
</div><!--<img class="select-box__icon" src="http://cdn.onlinewebfonts.com/svg/img_465802.svg" alt="Arrow Icon" aria-hidden="true">-->
<img class="select-box__icon" src="http://cdn.onlinewebfonts.com/svg/img_5121.svg" alt="Arrow Icon" aria-hidden="true">
<img class="select-box__icon" src="http://cdn.onlinewebfonts.com/svg/img_5121.svg" alt="Arrow Icon" aria-hidden="true">
</div>
<ul class="select-box__list">
<li>
<label class="select-box__option" for="0" aria-hidden="aria-hidden">One</label>
</li>
<li>
<label class="select-box__option" for="1" aria-hidden="aria-hidden">Two</label>
</li>
<li>
<label class="select-box__option" for="2" aria-hidden="aria-hidden">Three</label>
</li>
<li>
<label class="select-box__option" for="3" aria-hidden="aria-hidden">Four</label>
</li>
<li>
<label class="select-box__option" for="4" aria-hidden="aria-hidden">Five</label>
</li>
</ul>
</div>
html,
body {
min-height: 100%;
margin: 0;
}
body {
padding: 30px;
background-image: linear-gradient(45deg, #f5f7fa 0%, #c3cfe2 100%);
box-sizing: border-box;
}
.select-box {
position: relative;
display: block;
width: 100%;
margin: 0 auto;
font-size: 18px;
color: #60666d;
}
@media (min-width: 768px) {
.select-box {
width: 70%;
}
}
.select-box__current {
position: relative;
box-shadow: 0 15px 30px -10px rgba(0, 0, 0, 0.1);
cursor: pointer;
outline: none;
}
.select-box__current:focus + .select-box__list {
opacity: 1;
-webkit-animation-name: none;
animation-name: none;
}
.select-box__current:focus + .select-box__list .select-box__option {
cursor: pointer;
}
.select-box__current:focus .select-box__icon {
-webkit-transform: translateY(-50%) rotate(180deg);
transform: translateY(-50%) rotate(180deg);
}
.select-box__icon {
position: absolute;
top: 50%;
right: 15px;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
width: 20px;
opacity: 1;
transition: 0.2s ease;
}
.select-box__icon:nth-of-type(2) {
-webkit-transform: translateY(-50%) rotate(90deg);
transform: translateY(-50%) rotate(90deg);
}
.select-box__value {
display: flex;
}
.select-box__input {
display: none;
}
.select-box__input:checked + .select-box__input-text {
display: block;
}
.select-box__input-text {
display: none;
width: 100%;
margin: 0;
padding: 15px;
background-color: #fff;
}
.select-box__list {
position: absolute;
width: 100%;
padding: 0;
list-style: none;
opacity: 0;
-webkit-animation-name: HideList;
animation-name: HideList;
-webkit-animation-duration: 0.5s;
animation-duration: 0.5s;
-webkit-animation-delay: 0.5s;
animation-delay: 0.5s;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
-webkit-animation-timing-function: step-start;
animation-timing-function: step-start;
box-shadow: 0 15px 30px -10px rgba(0, 0, 0, 0.1);
}
.select-box__option {
display: block;
padding: 15px;
background-color: #fff;
}
.select-box__option:hover, .select-box__option:focus {
color: #546c84;
background-color: #fbfbfb;
}
@-webkit-keyframes HideList {
from {
-webkit-transform: scaleY(1);
transform: scaleY(1);
}
to {
-webkit-transform: scaleY(0);
transform: scaleY(0);
}
}
@keyframes HideList {
from {
-webkit-transform: scaleY(1);
transform: scaleY(1);
}
to {
-webkit-transform: scaleY(0);
transform: scaleY(0);
}
}
//Switch Option
$('input[type=radio][name=Ben]').change(function() {
console.log(this.value);
//window.location.href = this.value;
});
var countFocus = 0;
//Close Switch
$('.select-box__current').on('click', function() {
if ($(this).is(':focus')) {
countFocus++;
if (countFocus == 2) {
this.blur();
countFocus = 0;
}
}
});
This Pen doesn't use any external CSS resources.