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 7015589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:40:20+00:00 2026-05-27T22:40:20+00:00

I am trying to set up padding on some \ elements styled as pills,

  • 0

I am trying to set up padding on some \ elements styled as pills, and I want to dynamically change the padding. I know I can do:

@pill-padding-v: 8px;
@pill-padding-h: 15px;

padding:@pill-padding-v @pill-padding-h;

that renders this – and seems to work fine:

padding:8px 15px;

But how can I have LESS add 1px of padding to that?

@pill-padding-v: 8;
@pill-padding-h: 15;

@pill-padding-v: (@pill-padding-v + 1)
@pill-padding-h: (@pill-padding-h + 1)

padding:@pill-padding-vpx @pill-padding-hpx;

The main probelem seems to be adding “px” as part of the variable name I’m getting a compile error. Also I think it is syntactically incorrect to use 8 px instead of 8px and that seems to break in browsers, too.

How can I have multiply a pixel width value with LESS Css?

  • 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-27T22:40:20+00:00Added an answer on May 27, 2026 at 10:40 pm

    You’re right that adding the px to the variable is causing problems. I actually tried the interpolation syntax and it didn’t help, but you should be specifying units anyways in your variables (px, em, %…), like in your first working example.

    You said “multiply” but I think you meant “add”. There shouldn’t be any problem, try this:

    @pill-padding-v: 8px;
    @pill-padding-h: 15px;
    
    @pill-padding-v: (@pill-padding-v + 1);
    @pill-padding-h: (@pill-padding-h + 1);
    
    element {
        padding:@pill-padding-v @pill-padding-h;
    }
    

    Output should be:

    element { padding:9px 16px; }
    

    …although, you might want to just use another variable name or add the 1px right in the style declaration. I don’t think re-declaring variables is good practice, and was actually surprised it worked.

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

Sidebar

Related Questions

I'm trying to place some text and form elements into a Google Maps InfoWindow
I am trying to add some extra padding to the right side of a
I'm trying to pass some POST variables from hidden inputs (using JQuery to change
Im trying set the single table inheritance model type in a form. So i
I am trying set up databinding as described in the title. The problem I
Trying to set up caching on our datasets - we're using clr stored procedures
Trying to set it so if a certain condition is met then one of
Trying to set up a dependency in C++ with a parent-child relationship. The parent
Im trying to set up a session and i am getting a header error,
Im trying to set the certificate friendly name during the certificate request/acceptance process. I

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.