我把SVG图片放在某个区块里,区块变大了
我曾尝试更改svg属性,但后来得到了不同的图像外观-轮廓路径变得更粗
Html代码
<section class="image item item2 cat_image">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="isolation:isolate" viewBox="0 0 640 800" width="640pt" height="800pt"><defs>
<path...></g>
</svg>
</section>CSScode
svg {
transform: scale(0.45);
transform-origin: bottom;
}我想块的宽度是一样的svg图片。
更新:同样,如果我为块设置宽度,使其紧凑,那么图像也会缩小
发布于 2019-10-11 18:06:41
保利_D提出的使用display: inline-block的建议应该是正确的解决方案。
这就是我在下面的示例中使用的,它工作得很好。
section {
display: inline-block;
background: linen;
}
.smaller {
width: 300px;
height: 400px;
overflow: hidden;
}<section>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="isolation:isolate" viewBox="0 0 640 800" width="640pt" height="800pt">
<ellipse cx="320" cy="400" rx="320" ry="400" fill="rebeccapurple"/>
</svg>
</section>
<p/>
<section class="smaller">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="isolation:isolate" viewBox="0 0 640 800" width="640pt" height="800pt">
<ellipse cx="320" cy="400" rx="320" ry="400" fill="rebeccapurple"/>
</svg>
</section>
发布于 2019-10-11 00:09:33
<style>
div.outer{
background:red;
width:200px;
}
</style>
<div class="outer">
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" height="100pt">
<path d="M50,40 l100,0 0,50 -100,0 0,-50"
style="stroke: #000000; fill:green;" />
</svg>
</div>https://stackoverflow.com/questions/58326358
复制相似问题