How to calculate percentages in LESS CSS?

前端 未结 2 1334
太阳男子
太阳男子 2020-12-13 00:29

I would like to calculate the width of child-container (div etc) in percentages depending on the parent container with LESS CSS.

I am using the forumula by Ethan Mar

2条回答
  •  悲&欢浪女
    2020-12-13 01:02

    According to the LESS CSS website, you need to change the order of your equation

    The output is pretty much what you expect—LESS understands the difference between colors and units. If a unit is used in an operation, like in:

    @var: 1px + 5;
    

    LESS will use that unit for the final output—6px in this case.

    It should be:

    width: 100%*(140/620);
    

提交回复
热议问题