微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

CSS宽度减法

如何减去CSS中的宽度?

例如:

width = 100% – 10px

我不是在说填充或边距。

解决方法

现在 calc解决方案将是:
width: calc(100% - 10px);

Calc可以使用加法,减法,乘法,除法。

附加说明:

Note: The + and – operators must always be surrounded by whitespace. The operand of calc(50% -8px) for instance will be parsed as a percentage followed by a negative length,an invalid expression,while the operand of calc(50% – 8px) is a percentage followed by a minus sign and a length. Even further,calc(8px + -50%) is treated as a length followed by a plus sign and a negative percentage. The * and / operators do not require whitespace,but adding it for consistency is allowed,and recommended.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。