我有一个 svg,它应该是身体的 100% 宽度,它在 ie11、chrome 和 firefox 中工作 - 但在 safari 中,svg 的两侧都有一些空间,我无法摆脱它。任何帮助表示赞赏 - 请参阅此处的小提琴:http : //jsfiddle.net/tbbtester/2apEh/
css:
body{margin:0;padding:0;background:orange;}
.top {position: absolute;width: 100%;}
.inner{height:0;position: relative;padding-top:3.2%;}
svg{height: 100%;display:block;width: 100%;position: absolute;top:0;left:0;}
rect{stroke:none;fill:teal;}
Run Code Online (Sandbox Code Playgroud)
标记:
<div class="top">
<div class="inner">
<svg viewBox='0 0 100 3.2' preserveAspectRatio="xMidYMid meet">
<rect x="0" y="0" height="3.2" width="100"/>
</svg>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)