gpt4 book ai didi

html - 字体很棒,相同的图标不同宽度

转载 作者:行者123 更新时间:2023-11-27 23:30:19 25 4
gpt4 key购买 nike

我对 Font Awesome 图标有点问题。

我有 2 个相同版本的网站(用于开发和测试),图标显示不同,但具有相同的 CSS 样式。

我用这个图标描述了这个问题:

Font awesome, same icon with different width

.btnFilter {
color: #666666;
padding-top: 4px;
font-size: 18px;
text-align: center;
}
.circle {
border: solid #999 1px;
border-radius: 13px;
box-sizing: border-box;
width: 26px;
height: 26px;
text-align: center;
font-size: 18px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/>

<i class="fa fa-times circle btnFilter"></i>

这个 CSS 和 HTML 标记被放置在开发和测试版本上,chrome 开发工具显示相同的样式,并且悬停 font-awesome 图标:在伪元素的大小给出如上图所示的结果之前。

最佳答案

我认为在这里使用 em 而不是 px 值会更好……然后一切都会根据字体大小进行调整。

至于您的具体问题,font-awesome 中的 line-height/font-size 与您的特定样式之间存在冲突。

也可能不需要顶部填充。

html {
box-sizing: border-box;
}
*,
*::before,
*::after {
box-sizing: inherit;
margin: 0;
padding: 0;
}
.btnFilter {
color: #666666;
font-size: 160px !important;
/* for demo only */
line-height: 1em;
text-align: center;
}
.fa::before {
line-height: inherit;
}
.circle {
border: solid #999 1px;
border-radius: 50%;
width: 1.1em;
height: 1.1em;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" />
<i class="fa fa-times circle btnFilter"></i>

Codepen Demo

关于html - 字体很棒,相同的图标不同宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36222345/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com