我今天看到一些代码,其中作者将长度声明为<numeric value>%<numeric value>
CSS:width: 100%25;
HTML/SVG:width="100%25"
我已经写CSS很多年了,从来没有见过这样的长度声明。它似乎可以在HTML、SVG和CSS中工作。
这是某种形式的速记吗?这是什么意思?我试着寻找答案,但这个话题的性质让我很难找到答案。
原始代码:
<svg viewBox='0 0 900 900' xmlns='http://www.w3.org/2000/svg'>
<foreignObject width='100%25' height='100%25'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<style>
.c{
display:flex;
align-items:center;
justify-content:center;
margin:0;
width:100%25;
height:900px
}
.b{
width:33.33%25;
height:33.33%25;
background:red
}
</style>
<div class='c'>
<div class='b'/>
</div>
</div>
</foreignObject>
</svg>
您正在查看的代码包含百分比编码的%
字符,这些字符(到目前为止(尚未编码。
如果你百分比编码:
%
你得到:
%25
进一步阅读:
- https://en.wikipedia.org/wiki/Percent-encoding