'how can I make this dynamic line in css which shows rating in popup accordingly
Solution 1:[1]
Here you go : Not exactly but almost same.
var step = 10;
$(".slider").each(function() {
var self = $(this);
var slider = self.slider({
create: function() {
self.find('#tooltip').text(self.slider('value'));
},
slide: function(event, ui) {
self.find('#tooltip').text(self.slider('value'));
self.on('mouseup touchend', setPathData);
self.on('mousedown touchstart', setPathData1);
},
range: 'min',
min: 1,
max: step,
value: 1,
step: 0.1
});
});
function setPathData() {
$(this).find('.puls').addClass('active')
$(this).find('.puls').addClass(' color')
}
function setPathData1() {
$(this).find('.puls').removeClass('active')
$(this).find('.puls').removeClass('color')
}
.slider {
width: 320px;
height: 2px;
background: rgba(0, 0, 0, 0.2);
border-radius: 2px;
position: relative;
}
.slider .ui-slider-range {
border-radius: 2px;
background: #f9b315;
position: absolute;
left: 0;
top: 0;
bottom: 0;
}
.slider .ui-slider-handle {
cursor: move;
cursor: grab;
cursor: -moz-grab;
cursor: -webkit-grab;
width: 23px;
height: 23px;
position: absolute;
outline: none;
top: 0;
z-index: 1;
transform: translate(-50%, -50%);
transition: box-shadow 0.3s ease;
opacity: 1;
transition: width 0.3s ease;
}
.slider .ui-slider-handle svg {
fill: #FFF;
}
.slider .ui-slider-handle:after {
content: "";
position: absolute;
opacity: 0;
top: 0;
left: 0;
width: 28px;
height: 28px;
border-radius: 50%;
background: rgba(202, 239, 255, 0.6);
z-index: -1;
transform: translateZ(-1px);
}
.slider .ui-slider-handle.active:after {
animation: anim-effect-sanja 1.1s ease-out forwards;
}
.slider .ui-slider-handle.color svg {
fill: #f9b315;
}
.slider .ui-slider-handle.ui-state-active {
cursor: grabbing;
cursor: -moz-grabbing;
cursor: -webkit-grabbing;
width: 28px;
height: 28px;
}
.slider .text {
position: absolute;
bottom: 100%;
left: 0;
right: 0;
display: flex;
justify-content: space-between;
font-size: 16px;
transform: translate(0, -80px);
transition: transform 0.3s ease 0s;
}
.slider .text strong {
color: #000;
font-weight: bold;
}
@keyframes anim-effect-sanja {
0% {
opacity: 1;
transform: scale3d(0.5, 0.5, 1);
}
25% {
opacity: 1;
transform: scale3d(1.5, 1.5, 1.5);
}
100% {
opacity: 0;
transform: scale3d(1, 1, 1);
}
}
html {
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
}
* {
box-sizing: inherit;
}
*:before, *:after {
box-sizing: inherit;
}
body {
min-height: 100vh;
font-family: Roboto, Arial;
color: #ADAFB6;
display: flex;
justify-content: center;
align-items: center;
background: #fff;
}
#tooltip{
position: absolute;
width: 30px;
background-color: #fff;
color: #000;
text-align: center;
padding: 2px 0;
font-size: x-small;
border-radius: 6px;
z-index: 1;
transition: opacity .6s;
transform: translate(26px ,3px);
box-shadow: 0 4px 24px 0 rgb(161 161 161 / 97%);
}
#tooltip::after {
content: "";
position: absolute;
top: 50%;
box-shadow: 0 4px 24px 0 rgb(161 161 161 / 97%);
right: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent #cdcdcd transparent transparent;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<div class="slider">
<div class="ui-slider-handle puls">
<span id="tooltip"> </span>
<svg viewBox="0 0 35 35" fill="none" xmlns="http://www.w3.org/2000/svg">
<g filter="url(#filter0_d)">
<circle cx="17.5" cy="15.5" r="11.5" />
<circle cx="17.5" cy="15.5" r="11.5" />
</g>
<defs>
<filter id="filter0_d" x="0" y="0" width="35" height="35" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix" />
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" />
<feOffset dy="2" />
<feGaussianBlur stdDeviation="3" />
<feColorMatrix type="matrix" values="0 0 0 0 0.0666667 0 0 0 0 0.0666667 0 0 0 0 0.0666667 0 0 0 0.22 0" />
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow" />
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape" />
</filter>
</defs>
</svg>
</div>
</div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rootShiv |

