html - 如何更改 svg 图标的笔画宽度?
问题描述
我有我的 svg 图标,风格非常简单。我想将此图标的笔画宽度更改为 2px。我将 svg 样式的笔画宽度更改为 2,但图标的顶部已被切断。
有人知道如何将此属性设置为具有笔画宽度:2 但没有任何削减?
https://jsfiddle.net/kgpj1n06/13/
.header__button-icon {
width: 24px;
height: auto;
}
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" class="header__button-icon" width="21" height="21" viewBox="1.5 2 21 21">
<defs>
<style>.a{fill:none;stroke:#200e32;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-width:1.5px;}</style>
</defs>
<g transform="translate(2.778 2.778)">
<circle class="a" cx="8.989" cy="8.989" r="8.989"></circle>
<path class="a" d="M0,0,3.524,3.515" transform="translate(15.24 15.707)"></path>
</g>
</svg>
解决方案
调整视图框大小。随着您的形状变大,您的 viewBox 也需要变得更大,以便它包含整个展开的形状。
.header__button-icon {
width: 24px;
height: auto;
}
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" class="header__button-icon" width="21" height="21" viewBox="1.5 1.5 21 21.5">
<defs>
<style>.a{fill:none;stroke:#200e32;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-width:2px;}</style>
</defs>
<g transform="translate(2.778 2.778)">
<circle class="a" cx="8.989" cy="8.989" r="8.989"></circle>
<path class="a" d="M0,0,3.524,3.515" transform="translate(15.24 15.707)"></path>
</g>
</svg>
推荐阅读
- ruby-on-rails - Rails 包括被破坏的子代以响应父代的破坏
- r - Calculating the time spent with dates and time format in r
- c# - 仅下载 Azure Blob 的前几个字节
- maven - 从依赖项中读取 pom.xml 中的文件 - Maven
- cordova - 运行 ionic cordova build 命令时,你能帮我解决这个构建失败的问题吗
- azure-devops-rest-api - 在 AzureDevOps 服务器(本地)中,如何获取上次查看拉取请求时的时间戳?
- php - 如何从 POST 请求中正确输出特定的 cURL 响应
- d3.js - 带有分箱时间数据的 dc 折线图不显示空箱
- javascript - 上传失败,gapi php
- delphi - 在 Delphi 2007 项目中使用 Delphi 10.3 组件甚至是可能的。有解决方法吗?