我99%肯定CSS属性值的浮点数的前导零不是必需的,但我想确保,所以我在Codepen上测试了以下动画(here is the JSFiddle,因为我没有Codepen帐户)。该CSS是这样的:在什么情况下简化CSS属性需要用空格分隔longhand组件?
div {animation:xxx infinite .99s; width: 100px; height: 100px; background: linear-gradient(to right,gold,green,blue,red,black)}
@keyframes xxx {from {margin-left: 10px} to {margin-left: 1000px}}
然后我做了一个错字 - 而学会了一些在这个过程中CSS!我删除了“无限” animation-iteration-count
属性为animation-duration
价值和“.99s”之间的空间,并发现它没有打破动画(see this JSFiddle):
div {animation:xxx infinite.99s; width: 100px; height: 100px; background: linear-gradient(to right,gold,green,blue,red,black)} // deleted space between infinite and .99s
@keyframes xxx {from {margin-left: 10px} to {margin-left: 1000px}}
我去W3文档CSS动画 - 特别是the animation property,即使示例(示例#6)显示<single-animation>
与空格分隔的长手属性值,无处(我发现)是否需要空格(并且我抬头看double bar ||,我没有看到任何提及所需空间)。
值得注意的是,以下的(这将插入一个“0”之前的0.99小数点)不打破动画(Fiddled here):我想考某种共性,发现another case
div {animation:xxx infinite0.99s; width: 100px; height: 100px; background: linear-gradient(to right,gold,green,blue,red,black)} // added a "0" between infinite and .99s
@keyframes xxx {from {margin-left: 10px} to {margin-left: 1000px}}
使用速记border
属性:
div {animation: xxx infinite0.99s; width: 100px; height: 100px; background: green; border: solid red.99px}
@keyframes xxx {from {margin-left: 10px} to {margin-left: 1000px}}
我重复上面一样使用“0”,并得到了相同的结果。
在什么情况下做简短的CSS属性要求用空格分开longhand组件?
好的答案....所以一个缩小器可以正确地删除所有这些零(作为一个这样的应用程序) –