Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4018938
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:02:41+00:00 2026-05-20T10:02:41+00:00

In less.js, I’m able to replace values with variables with no problems. @gutter: 20px;

  • 0

In less.js, I’m able to replace values with variables with no problems.

@gutter: 20px;
margin-left:e(%("-%d"), @gutter);

When trying to replace properties with variables, I get errors. How would I perform the following in Less?

@gutter: 20px;
@direction: left;
e(%("margin-%d"), @direction):e(%("-%d"), @gutter);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:02:41+00:00Added an answer on May 20, 2026 at 10:02 am

    Thanks to Alvivi for the solution and research (you get the reward for that). I decided to add the following as the actual answer since this is a real way to set it up instead of looking at .blah() pseudo code..

    Here’s a real strategy for setting it up:

    @gutter: 20px;
    @dir: left;
    @dirOp: right;
    

    then create mixins to enhance margin and padding like so:

    .margin(left, @dist:@gutter) {
        margin-left:@dist;
    }
    .margin(right, @dist:@gutter) {
        margin-right:@dist;
    }
    .padding(left, @dist:@gutter) {
        padding-left:@dist;
    }
    .padding(right, @dist:@gutter) {
        padding-right:@dist;
    }
    .lr(left, @dist: 0) {
        left: @dist;
    }
    .lr(right, @dist: 0) {
        right: @dist;
    }
    

    .. then you can just

    #selector {
        .margin(@dir);
    } 
    

    or

    #selector {
        .margin(@dirOp, 10px);
    }
    

    all together:

    #selector {
        .margin(@dir);
        .margin(@dirOp, 50px);
        .padding(@dir, 10px);
        .padding(@dirOp);
        float:@dir;
        text-align:@dirOp;
        position:absolute;
        .lr(@dir);
    }
    

    Easy breezy LTR/RTL with LESS! Woot!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using LESS and im trying for a type of mixin. I have
I have created a LESS mixin for margins that accepts multiple numeric values and
Do const fields use less memory than regular variables?
This is more or less my first java project. I can't get my while
In Less , it seems almost impossible to use @font-face selector. Less gives errors
Using LESS CSS I was able to restrict entire stylesheets to acting on a
This is more or less a simplified version of the issue I'm trying to
I'm a LESS user, but I'm considering trying out Sass. Each of them have
I've inherited a less-than-ideal table structure, and I'm trying to improve it as much
Is there a plugin-less way of retrieving query string values via jQuery (or without)?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.