Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

数学运算:less编译为css是,除法没有被编译成功,这是一个bug嘛? #540

Closed
huangyangquang opened this issue Jan 30, 2021 · 1 comment

Comments

@huangyangquang
Copy link

less文件:
`@width: 100px;
@height: @width / 10;

div {
width: @width;
height: @height;
border: 1px solid #000;
position: relative;
top: 100px 100px;
left: 100px - 2;
margin: 10px * 2;
padding: 10px / 2;
}`

编译命令: lessc styles.less styles.css
编译后产生的css文件:
div { width: 100px; height: 100px / 10; border: 1px solid #000; position: relative; top: 200px; left: 98px; margin: 20px; padding: 10px / 2; }

有人知道是怎么回事嘛?

@iChenLei
Copy link
Member

parens-division (4.0 default) - No division is performed outside of parens using / operator (but can be "forced" outside of parens with ./ operator - ./ is deprecated)

Did you use less v4 ? If you use v4, you need change youe code like follow:

@width: 100px;
@height: @width / 10;

div {
  width: @width;
  height: @height;
  border: 1px solid #0;
  position: relative;
  top: 100px   100px;
  left: 100px - 2;
  margin: 10px * 2;
  padding: (10px / 2);  // <- add parens ()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants