Last active
March 3, 2021 01:15
-
-
Save Inontran/5fec3835851aeea4ad38680a1e1d2e12 to your computer and use it in GitHub Desktop.
код рейтинга со звездочками
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 ------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment