As the title stated, how would I debug less css variables. For an example.
//style.less
@height: `document.body.clientHeight`;
Because less is a great tool to compile css in a programming way and css variable has the feature of dynamtic value and is a good way to switch theme. It's true that is less can't use css variables in less function.
Create a stylesheet with . less extension and link it in your document using the rel="stylesheet/less" attribute. You are all set and can compose styles within the . less .
Based on @GeekyMonkey's answer, I wrote this little snipped you can put somewhere in your less file:
.debug(@var) {
&:after {
content: "@{var}";
font-size: 20px;
background-color: #fff;
border: 1px solid red;
padding: 10px;
border-radius: 5px;
color: red;
font-weight: bold;
position: absolute;
top: 50%;
left: 50%;
}
}
Then just use .debug(@someVar)
and get its value printed to the screen. :-)
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