Skip to content

Instantly share code, notes, and snippets.

@Inontran
Last active March 3, 2021 01:15
Show Gist options
  • Select an option

  • Save Inontran/5fec3835851aeea4ad38680a1e1d2e12 to your computer and use it in GitHub Desktop.

Select an option

Save Inontran/5fec3835851aeea4ad38680a1e1d2e12 to your computer and use it in GitHub Desktop.
код рейтинга со звездочками
<div class="rate-star">
<div class="rate-star__stars-wrapper">
<input type="hidden" class="rate-star__input" value="3.5" readonly="" />
<span class="rate-star__star" data-number-star="5"></span>
<span class="rate-star__star" data-number-star="4"></span>
<span class="rate-star__star" data-number-star="3"></span>
<span class="rate-star__star" data-number-star="2"></span>
<span class="rate-star__star" data-number-star="1"></span>
</div>
</div>
// RATE-STAR ------------
.rate-star{
display: inline-flex;
.rate-star__stars-wrapper{
display: inline-flex;
align-items: center;
flex-direction: row-reverse;
margin: 0 -5px;
}
.rate-star__star{
display: inline-block;
width: calc_rem(15);
height: calc_rem(15);
background-image: url(#{$STYLE_PATH}images/icons/star-orange-o.svg);
background-position: center;
background-repeat: no-repeat;
margin: 0 5px;
text-decoration: none;
border: 0;
box-shadow: none;
background-color: transparent;
}
@for $i from 0 through 5 {
.rate-star__input{
// значение кратное 1
&[value^="#{$i}"]{
@for $j from 0 through $i{
& ~ .rate-star__star[data-number-star="#{$j}"]{
background-image: url(#{$STYLE_PATH}images/icons/star-orange.svg);
}
}
}
// значение кратное 0.5
&[value="#{$i}.5"]{
& ~ .rate-star__star[data-number-star="#{$i + 1}"]{
background-image: url(#{$STYLE_PATH}images/icons/star-orange-half-o.svg);
}
}
}
}
.rate-star__input:not([readonly]) ~ .rate-star__star:hover{
&,
& ~ .rate-star__star{
background-image: url(#{$STYLE_PATH}images/icons/star-orange.svg);
}
}
}
// RATE-STAR ------------
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment