I need to convert percentage value (51%) to number (0.51)
What is the best way to do this?
My less snippet
// Gradients
#gradient {
.vertical-gloss(@startColor: #555, @endColor: #333, @firstColorStop:50%, @secondColorStart:51%) {
background-image: linear-gradient(bottom, @startColor @firstColorStop, @endColor @secondColorStart);
background-image: -o-linear-gradient(bottom, @startColor @firstColorStop, @endColor @secondColorStart);
background-image: -moz-linear-gradient(bottom, @startColor @firstColorStop, @endColor @secondColorStart);
background-image: -webkit-linear-gradient(bottom, @startColor @firstColorStop, @endColor @secondColorStart);
background-image: -ms-linear-gradient(bottom, @startColor @firstColorStop, @endColor @secondColorStart);
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.5, @startColor), color-stop(0.51, @startColor));
background-repeat: repeat-x;
}
}
unit function to convert 50% to 50.For readability, I've used an auxiliary variable, as seen below:
.vertical-gloss(@startColor: #555, @endColor: #333, @firstColorStop:50%, @secondColorStart:51%) {
@firstColorStopPerc: (unit(@firstColorStop) / 100);
@secondColorStopPerc: (unit(@secondColorStart) / 100);
/* ... skipped non-relevant pieces ... */
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(@firstColorStopPerc, @startColor), color-stop(@secondColorStopPerc, @startColor));
background-repeat: repeat-x;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With