提问者:小点点

<number>%<number>在CSS长度中意味着什么,例如100%25


今天我遇到一些代码,作者将长度声明为%

css:宽度: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>

共1个答案

匿名用户

您正在查看的代码包含百分比编码的%字符,这些字符(到目前为止)仍未解码。

如果您进行百分比编码:

你得到:

进一步阅读:

  • https://en.wikipedia.org/wiki/percent-encoding