user1802439
user1802439

Reputation: 2891

css property value contains variable

How can I include a variable when setting a property value with less css. For example:

I want to set the background image on the right or on the left based on the variable @direction.

I've tried:

@direction:left;
background: url(../../images/downarrow_blue.png) no-repeat @direction white;

but it does not work.

Upvotes: 0

Views: 178

Answers (1)

Rubens Mariuzzo
Rubens Mariuzzo

Reputation: 29231

You have 2 issues:

  1. To pass string value variables you should encloss them into single quotes. In your case it should be @direction: 'left';.
  2. The background-position property accept two values corresponding to each axis. You need to pass something like: @direction: 'left top'; or @direction: 'right bottom';.

Check the documentation related to variables: http://lesscss.org/#-variables

Upvotes: 1

Related Questions