Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug less css variables

Tags:

css

less

As the title stated, how would I debug less css variables. For an example.

//style.less
@height: `document.body.clientHeight`;
like image 951
TonyTakeshi Avatar asked May 17 '12 10:05

TonyTakeshi


People also ask

Can I use CSS variables in less?

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.

How do you write less in CSS?

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 .


1 Answers

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. :-)

like image 111
Joshua Muheim Avatar answered Sep 27 '22 21:09

Joshua Muheim