不识别calc,CSS3 calc(100%-88px)在Chrome中不起作用

I noticed that my usage of the CSS3 calc() function as the unit for width is not working in the latest version of Chrome.

In the Chrome Developer tools, the rule with calc() has a strikethrough through it and an exclamation mark in a yellow triangle to the left of it. This is signaling that the property or value is not recognized.

How do I get it to work in modern browsers? Because it is a value and not a property, where do the vendor prefixes go?

Update:

When I say it doesn't work, I mean that Chrome Dev Tools is saying that it is not recognizing my usage of it width: calc(100%-88px);. How do I know it is not recognizing it? Because of the strikethrough and the yellow triangle icon next to the style rule in chrome dev tools.

解决方案

The problem in the question was caused by the lack of space around the subtraction operator.

Note that the grammar requires spaces around binary ‘+’ and ‘-’

operators. The ‘*’ and ‘/’ operators do not require spaces.

I speculate that this is to make clear the differentiation between operators and signed numbers.

Bad: calc(100%-88px)

Good: calc(100% - 88px)

How do I know it is not recognizing it? Because of the strikethrough

and the yellow triangle icon next to the style rule in chrome dev

tools.

A property that is struck in when viewed in Chrome's developer tools may be valid but overridden; however, a property struck through and with a warning triangle icon next to it is invalid.

Other Notes

Chrome has supported calc() for quite some time (confirmed on OSX and Windows).

Chrome may not support viewport units such as vh/vw inside calc(). As of late 2014, there is activity on implementing this, but the related bug is still open.

In my testing, Safari will support calc() with the -webkit vendor prefix on OSX but not Windows.

IE9+ supports calc() with no vendor prefix.

FF supports calc() with no vendor prefix.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值