问题
If I have this:
.box{
color: #FF3010;
background: hsl(0,90%,40%);
}
and then this:
var box = document.querySelector(".box");
var result = document.querySelector(".result");
result.innerHTML = "BG color: "+window.getComputedStyle(box).backgroundColor;
result.innerHTML += "<br>";
result.innerHTML += "color:"+window.getComputedStyle(box).color;
The problem is that it always prints the values in rgb. So, I have 2 questions:
- Is it posible to get the value as written in the css?
- Is it posible to force the color to be hsl instead of rgb?
来源:https://stackoverflow.com/questions/30440423/get-hsl-color-with-javascript