gpt4 book ai didi

html - 为什么 100% 等于 150 像素?

转载 作者:太空宇宙 更新时间:2023-11-04 02:30:03 25 4
gpt4 key购买 nike

以下代码生成一个 150 像素高的表格。为什么是 150?这是 SVG 怪癖还是更普遍的东西?

https://jsfiddle.net/cc9tyw5v/31/

<table class="root" cellspacing="0">
<tr>
<td>
<svg class="root-symbol" viewBox="0 0 5 6.5" preserveAspectRatio="none" style="height:100%;background-color:lightgreen;">
<text x="0" y="6.5" font-size="9px">a</text>
</svg>
</td>
<td><span style="font-size:2em;background-color:lightblue">I would expect it to be as tall as this span</span></td>
</tr>
</table>

最佳答案

根据 this source

SVG isn't (just) an image. SVG is a document. The default size for HTML replaced elements will be used: 300px wide, 150px tall. This applies for <img>, <object> or <iframe>. The default 300x150 size also applies to inline <svg> elements within HTML documents, but that's a relatively recent consensus from the HTML5 specifications: other browsers will by default expand inline SVG to the full size of the viewport—equivalent to width: 100vw; height: 100vh; — which is the default size for SVG files that are opened directly in their own browser tab. Internet Explorer cuts the difference, using width of 100% and height of 150px for images and inline SVG.

关于html - 为什么 100% 等于 150 像素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36673974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com