html - IE11 browser shape overflows SVG element
问题描述
I'm working on an SVG and trying to create half circle but the IE11 browser creates complete circle instead.
My code is like this:
<svg viewBox="0 0 80 40" class="gauge">
<circle
cx="40"
cy="40"
r="37"
fill="transparent"
stroke="#d2d3d4"
stroke-width="6"></circle>
</svg>
How can I render half circle in IE11? It is working fine on other browsers. Please find the below image for more reference.
On IE11 :
On Chrome :
解决方案
A quick fix would be to add overflow:hidden;
on the svg like so :
svg {
overflow: hidden;
}
<svg viewBox="0 0 80 40" class="gauge">
<circle
cx="40"
cy="40"
r="37"
fill="transparent"
stroke="#d2d3d4"
stroke-width="6"></circle>
</svg>
Depending on your use case, a "cleaner" solution would be to build your half circle with a path and the arc command :
<svg viewBox="0 0 80 40" class="gauge">
<path d="M3 40 A37 37 0 0 1 77 40"
fill="transparent"
stroke="#d2d3d4"
stroke-width="6" />
</svg>
This way you are sure nothing overflows the svg element.
推荐阅读
- python - 为什么在pygame中文本显示2秒
- javascript - 焦点边框颜色变化
- matlab - 在 MATLAB App Designer 中正确使用 uiwait 和 uiresume
- html - 如何在 Django 中编辑布尔字段
- vba - 打开一个新数据库并关闭旧数据库
- php - 如何为 Phinx 添加列字符变化(3)[]
- python - 有没有办法在给定的 pytorch 或 tensorflow 模型的推理过程中获得总的 Flops?
- android - Kotlin - Retrofit - rxjava3 - setImage 使用数据绑定 [已解决]
- python - 如何使用 python 从列表中读取数据并将特定值索引到 Elasticsearch 中?
- javascript - 传播一个可迭代的 ...obj[Symbol.iterator](...)