A
A
Alexander Loginov-Solonitsyn2015-12-24 10:23:55
css
Alexander Loginov-Solonitsyn, 2015-12-24 10:23:55

How to access a property in less/sass?

The essence of the question is simple.
For example, we have this code:

h1 {
  color: red;
  &:hover {
    color: .that(color); // Эта строчка работать конечно же не будет, но её смысл я думаю понятен
    color: &(color); // Или так, но тоже не работает
  }
}

Meaning: I want to get the color of this element.
And in general it would be nice to know how to get colors in less.
ps. If anyone knows, for example, how such problems are solved, for example, in Sass / SCSS, then I will be very happy.
I looked at the docks, but didn’t see anything, maybe I missed it)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Loginov-Solonitsyn, 2015-12-30
@kasheibess

Long story short, I found a solution. The other day I decided to switch to stylus and there is this feature.
Everything will be written like this:

h1 {
  color: this_color = red;
  &:hover {
    color: this_color;
  }
}

or
h1 {
  color: red;
  &:hover {
    color: @color;
  }
}

In general, stylus seemed to me the most advanced, especially after less.
The syntax is simplified to a minimum. And it supports 2 types of syntax (in the style of Sass and SCSS), and they can be safely used in one file. From what I liked at first - variables:
color = #FFF;

A
Alexey Ukolov, 2015-12-24
@alexey-m-ukolov

It is for this purpose that variables are invented.

Z
zooks, 2015-12-24
@zooks

What's the problem? You declare a variable and you specify it where it is necessary.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question