<div id="info">
Observe the platform icon's motion direction when there is up and down
hover on options.
</div>
<form>
<input type="checkbox" id="options-checkbox-btn" />
<div id="select-btn" class="fx fx-justify-between">
<div id="selected-value">
<span>Select a platform</span>
</div>
<div id="chevrons">
<i class="fas fa-chevron-up"></i>
<i class="fas fa-chevron-down"></i>
</div>
</div>
<div id="options">
<div class="option">
<input class="option-radio-btn top" type="radio" name="platform" value="codepen" />
<input class="option-radio-btn bottom" type="radio" name="platform" value="codepen" />
<i class="fab fa-codepen"></i>
<span class="option-label">CodePen</span>
<span class="option-value">CodePen</span>
</div>
<div class="option">
<input class="option-radio-btn top" type="radio" name="platform" value="dribbble" />
<input class="option-radio-btn bottom" type="radio" name="platform" value="dribbble" />
<i class="fab fa-dribbble"></i>
<span class="option-label">Dribbble</span>
<span class="option-value">Dribbble</span>
</div>
<div class="option">
<input class="option-radio-btn top" type="radio" name="platform" value="behance" />
<input class="option-radio-btn bottom" type="radio" name="platform" value="behance" />
<i class="fab fa-behance"></i>
<span class="option-label">Behance</span>
<span class="option-value">Behance</span>
</div>
<div class="option">
<input class="option-radio-btn top" type="radio" name="platform" value="hackerrank" />
<input class="option-radio-btn bottom" type="radio" name="platform" value="hackerrank" />
<i class="fab fa-hackerrank"></i>
<span class="option-label">HackerRank</span>
<span class="option-value">HackerRank</span>
</div>
<div class="option">
<input class="option-radio-btn top" type="radio" name="platform" value="stackoverflow" />
<input class="option-radio-btn bottom" type="radio" name="platform" value="stackoverflow" />
<i class="fab fa-stack-overflow"></i>
<span class="option-label">StackOverflow</span>
<span class="option-value">StackOverflow</span>
</div>
<div class="option">
<input class="option-radio-btn top" type="radio" name="platform" value="freecodecamp" />
<input class="option-radio-btn bottom" type="radio" name="platform" value="freecodecamp" />
<i class="fab fa-free-code-camp"></i>
<span class="option-label">FreeCodeCamp</span>
<span class="option-value">FreeCodeCamp</span>
</div>
<div id="option-bg"></div>
</div>
</form>
* {
user-select: none;
}
*:focus {
outline: none;
}
html,
body {
height: 100%;
min-height: 100%;
}
body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
padding-bottom: 100px;
margin: 0;
background-color: #ebf3f3;
}
.fx {
display: flex;
}
.fx-justify-between {
justify-content: space-between;
}
#info {
position: absolute;
top: 0;
right: 0;
left: 0;
color: #2d3667;
font-size: 16px;
text-align: center;
padding: 14px;
background-color: #f3f9f9;
}
form {
position: absolute;
top: 0;
right: 0;
left: 0;
width: 300px;
height: 42px;
margin: 100px auto 0 auto;
z-index: 1;
}
#select-btn {
position: relative;
height: 16px;
padding: 12px 14px;
background-color: #fff;
border-radius: 4px;
cursor: pointer;
border: 1px solid #e2eded;
border-color: #eaf1f1 #e4eded #dbe7e7 #e4eded;
}
#options-checkbox-btn {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
margin: 0;
opacity: 0;
cursor: pointer;
z-index: 3;
}
#selected-value {
font-size: 16px;
line-height: 1;
margin-right: 26px;
}
.option i {
width: 16px;
height: 16px;
}
.option,
.option-label {
color: #2d3667;
font-size: 16px;
}
#chevrons i {
display: block;
height: 50%;
color: #d1dede;
font-size: 12px;
}
#options-checkbox-btn:checked + #select-btn #chevrons i {
color: #2d3667;
}
.options {
position: absolute;
left: 0;
width: 250px;
}
#options {
position: absolute;
top: 42px;
right: 0;
left: 0;
width: 298px;
margin: 0 auto;
background-color: #fff;
border-radius: 4px;
}
#options-checkbox-btn:checked ~ #options {
border: 1px solid #e2eded;
border-color: #eaf1f1 #e4eded #dbe7e7 #e4eded;
}
.option {
position: relative;
line-height: 1;
transition: 0.3s ease all;
z-index: 2;
}
.option i {
position: absolute;
left: 14px;
padding: 0;
display: none;
}
#options-checkbox-btn:checked ~ #options .option i {
display: block;
padding: 12px 0;
}
.option-label {
display: none;
padding: 0;
margin-left: 27px;
}
#options-checkbox-btn:checked ~ #options .option-label {
display: block;
padding: 12px 14px;
}
.option-radio-btn {
position: absolute;
left: 0;
width: 100%;
height: 50%;
}
.option-radio-btn.top {
top: 0;
}
.option-radio-btn.bottom {
bottom: 0;
}
input[type="radio"] {
position: absolute;
right: 0;
left: 0;
width: 100%;
height: 50%;
margin: 0;
opacity: 0;
cursor: pointer;
}
.option-radio-btn:hover ~ i {
color: #fff;
opacity: 0;
}
.option-radio-btn:hover {
height: 100%;
z-index: 1;
}
.option-radio-btn.bottom:hover + i {
bottom: -25px;
animation: moveup 0.3s ease 0.1s forwards;
}
.option-radio-btn.top:hover ~ i {
top: -25px;
animation: movedown 0.3s ease 0.1s forwards;
}
@keyframes moveup {
0% {
bottom: -25px;
opacity: 0;
}
100% {
bottom: 0;
opacity: 1;
}
}
@keyframes movedown {
0% {
top: -25px;
opacity: 0;
}
100% {
top: 0;
opacity: 1;
}
}
.option-label {
transition: 0.3s ease all;
}
.option-value {
position: absolute;
left: 14px;
width: 217px;
height: 21px;
opacity: 0;
background-color: #fff;
transform: scale(0);
}
.option input[type="radio"]:checked ~ .option-value {
opacity: 1;
transform: scale(1);
}
.option input[type="radio"]:checked ~ i {
top: 0;
bottom: auto;
opacity: 1;
animation: unset;
}
.option input[type="radio"]:checked ~ i,
.option input[type="radio"]:checked ~ .option-label {
color: #fff;
}
.option input[type="radio"]:checked ~ .option-label:before {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: -1;
}
#options-checkbox-btn:not(:checked)
~ #options
.option
input[type="radio"]:checked
~ .option-value {
top: -30px;
}
.option:nth-child(1) input[type="radio"]:checked ~ .option-label:before {
background-color: #000;
border-radius: 4px 4px 0 0;
}
.option:nth-child(1) input[type="radio"]:checked ~ .option-value {
top: -31px;
}
.option:nth-child(2) input[type="radio"]:checked ~ .option-label:before {
background-color: #ea4c89;
}
.option:nth-child(2) input[type="radio"]:checked ~ .option-value {
top: -71px;
}
.option:nth-child(3) input[type="radio"]:checked ~ .option-label:before {
background-color: #0057ff;
}
.option:nth-child(3) input[type="radio"]:checked ~ .option-value {
top: -111px;
}
.option:nth-child(4) input[type="radio"]:checked ~ .option-label:before {
background-color: #32c766;
}
.option:nth-child(4) input[type="radio"]:checked ~ .option-value {
top: -151px;
}
.option:nth-child(5) input[type="radio"]:checked ~ .option-label:before {
background-color: #f48024;
}
.option:nth-child(5) input[type="radio"]:checked ~ .option-value {
top: -191px;
}
.option:nth-child(6) input[type="radio"]:checked ~ .option-label:before {
background-color: #006400;
border-radius: 0 0 4px 4px;
}
.option:nth-child(6) input[type="radio"]:checked ~ .option-value {
top: -231px;
}
.option .fa-codepen {
color: #000;
}
.option .fa-dribbble {
color: #ea4c89;
}
.option .fa-behance {
color: #0057ff;
}
.option .fa-hackerrank {
color: #32c766;
}
.option .fa-stack-overflow {
color: #f48024;
}
.option .fa-free-code-camp {
color: #006400;
}
#option-bg {
position: absolute;
top: 0;
right: 0;
left: 0;
height: 40px;
transition: 0.3s ease all;
z-index: 1;
display: none;
}
#options-checkbox-btn:checked ~ #options #option-bg {
display: block;
}
.option:hover .option-label {
color: #fff;
}
.option:nth-child(1):hover ~ #option-bg {
top: 0;
background-color: #000;
border-radius: 4px 4px 0 0;
}
.option:nth-child(2):hover ~ #option-bg {
top: 40px;
background-color: #ea4c89;
}
.option:nth-child(3):hover ~ #option-bg {
top: 80px;
background-color: #0057ff;
}
.option:nth-child(4):hover ~ #option-bg {
top: 120px;
background-color: #32c766;
}
.option:nth-child(5):hover ~ #option-bg {
top: 160px;
background-color: #f48024;
}
.option:nth-child(6):hover ~ #option-bg {
top: 200px;
background-color: #006400;
border-radius: 0 0 4px 4px;
}
This Pen doesn't use any external JavaScript resources.