JSFiddle - React, Tailwind, and code Playground
by andrey90vs
HTML
<div class="container">
<div class="score">
<span>Score</span>
<div class="score_rate">
<div>0</div>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
</div><div class="score_drop score_plus"></div>
</div>
SCSS
* {
box-sizing: border-box;
}
.container {
width: 100%;
white-space: nowrap;
background-color: #fff;
text-align: center;
color: #fff;
}
.score {
display: inline-block;
position: relative;
border-right: 1px solid #fff;
width:55%;
max-width: 135px;
height: 75px;
background-color: #0075c0;
line-height: 75px;
border-bottom-left-radius: 10px;
border-top-left-radius: 10px;
}
.score_drop {
display: inline-block;
vertical-align: top;
cursor: pointer;
width:40%;
max-width: 80px;
height: 75px;
background-color: #0075c0;
border-bottom-right-radius: 10px;
border-top-right-radius: 10px;
&:hover {
background-color: rgba(0, 117, 192, 0.9);
}
img {
padding-top: 22px;
}
}
.score_minus {
background: url(http://s27.postimg.org/r11kdi38f/minus.gif) no-repeat;
background-position: center;
background-size: 50% 50%;
background-color: rgba(0, 117, 192, 0.6);
}
.score_plus {
background: url(http://s8.postimg.org/ctjou8l7l/plus.gif) no-repeat;
background-position: center;
background-size: 50% 50%;
background-color: #0075c0;
}
.score_rate {
display: none;
position: absolute;
background-color: #0075c0;
color: #fff;
padding: 0 2px;
left: 0;
width: 100%;
margin-top: 1px;
border-radius: 5px;
div {
width: 100%;
line-height: normal;
cursor: pointer;
padding: 5px 0;
margin: 2px 0;
background-color: rgba(0,0,0,0.1);
border-radius: 5px;
&:hover {
background-color: rgba(0,0,0,0.3);
}
}
}
JavaScript
$('.score_drop').click(function() {
$(this).parent().find('.score .score_rate').slideToggle(400, function(){
$(this).parent().parent().find('.score_drop').toggleClass('score_minus');
$(this).parent().parent().find('.score_drop').toggleClass('score_plus');
});
return false;
});