我有一个带有预设视口的 svg 框。我想显示它以使其 100% 通过。但是正在发生的事情是它在下面增加了空间。我怎样才能摆脱这个?我宁愿不必修改视口和内部组件的大小(它们是从需要这些的其他工具生成的),但我可以添加/修改 svg 标记的属性(例如纵横比)。我做了一个小提琴 - http://jsfiddle.net/cyberwombat/2MLwx/1/ - 我希望黑色框周围的红色边框为 2px。我尝试了一些 preserveAspectRatio 变体,但到目前为止还没有运气。
<!DOCTYPE html>
<head>
<style>
.frame {
margin:100px 100px 0 100px;
background-color:yellow;
}
.wrapper {
border:1px solid red;
padding:2px;
}
svg {
}
</style>
</head>
<body>
<div class="frame">
<div class="wrapper">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMinYMin meet" viewBox="0 0 800 150" width="100%" version="1.1">
<rect transform="matrix(1,0,0,1,0,0)" x="0" y="0" width="100%" height="100%" r="0" rx="0" ry="0" fill="#000" stroke="#000"></rect>
</svg>
</div>
Hello
</div>
</body>
</html>