Reduce the weight of a Glyphicon

落爺英雄遲暮 提交于 2019-12-21 04:25:23

问题


Is there a way to reduce the "weight" of Glyphicons?

I am using the "ok" Glyphicon <span class="glyphicon glyphicon-ok"></span> which displays like this:

Is there any way to reduce the weight to produce a thinner tick without reducing the font size? Changing the font-weight to lighter has no effect whatsoever.


回答1:


Using white stroke is a way to do it

-webkit-text-stroke: 2px white;



回答2:


You could apply the font-weight property on ::before pseudo element to alter the font-weight:

.glyphicon {
  font-size: 60px;
}

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

.glyphicon-thick::before {
  font-weight: 900;
}
<!-- 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">


<span class="glyphicon glyphicon-search glyphicon-light"></span>

<span class="glyphicon glyphicon-search"></span>

<span class="glyphicon glyphicon-search glyphicon-thick"></span>



回答3:


Works on Different background-color.

$(document).ready(function() {
    $( "[.fas || .glyphicon]" ).each(function( index ) {
      var color = $(this).parent().css("background-color");
      $(this).css("-webkit-text-stroke","2px "+color)
    });
});

Notice : choose one of .fas or .glyphicon .




回答4:


You can also use opacity on the glyphicon if you do not want to apply this globally.

<span style="opacity:0.25;" class="glyphicon glyphicon-ok"></span>


来源:https://stackoverflow.com/questions/42686104/reduce-the-weight-of-a-glyphicon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!