【问题标题】:Bootstrap Glyphicon, How to change weight?Bootstrap Glyphicon,如何改变重量?
【发布时间】:2022-02-22 22:39:04
【问题描述】:

我没有看到我可以在 CSS 属性 font-weight 中指定的任何值发生任何变化。你知道怎么解决吗?

提前致谢

.glyphicon-custom {
  font-weight: lighter;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

<div class="form-group has-feedback"><input type="search" class="form-control"/><span class="glyphicon glyphicon-search form-control-feedback glyphicon-custom"></span></div>

【问题讨论】:

标签: css twitter-bootstrap


【解决方案1】:

您需要将font-weight 应用于::before 伪元素,因为它是写入内容的位置。

在下面的 sn-p 中,我分别为图标指定了字体权重 100 和 900。

.glyphicon-custom::before {
  font-weight: 100;
}

.glyphicon-custom-2::before {
  font-weight: 900;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<div class="form-group has-feedback"><input type="search" class="form-control"/><span class="glyphicon glyphicon-search form-control-feedback glyphicon-custom"></span></div>


<div class="form-group has-feedback"><input type="search" class="form-control"/><span class="glyphicon glyphicon-search form-control-feedback glyphicon-custom-2"></span></div>

【讨论】:

  • 感谢@Nisarg 的解决方案。只是一个问题:我可以使用来自引导程序的字形图标的最大亮度为 100 吗?我试图减少更多,但看起来这是“最大值”..
  • @Micky 是的,字体库通常控制它们支持的值。浏览器支持的数值是 100、200、300 ... 900。不过我不太确定 bootstrap 支持哪些值。
【解决方案2】:
.someSvg path {
    stroke: white;
    stroke-width: 3px;
}
    <div style="width: 100px; height:100px;">
      <svg viewBox="-10 -10 120 120" class="someSvg>
        <path d="M 50,0 L 60,10 L 20,50 L 60,90 L 50,100 L 0,50 Z" class="arrow" transform="translate(85,100) rotate(180)"></path>
      </svg>
    </div>

【讨论】:

  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-19
  • 2017-07-29
  • 1970-01-01
  • 1970-01-01
  • 2013-09-16
  • 2013-10-25
相关资源
最近更新 更多