【发布时间】:2022-03-25 20:48:22
【问题描述】:
我正在使用以下引导图标
class="glyphicon glyphicon-plus"
我想改变按钮的颜色,我使用以下 但是现在我希望加号图标会像这样在圆圈中,我该怎么做?
i.glyphicon {
color: white;
}
【问题讨论】:
标签: css twitter-bootstrap
我正在使用以下引导图标
class="glyphicon glyphicon-plus"
我想改变按钮的颜色,我使用以下 但是现在我希望加号图标会像这样在圆圈中,我该怎么做?
i.glyphicon {
color: white;
}
【问题讨论】:
标签: css twitter-bootstrap
另一个名为font-awesome 的图标包具有更好的灵活性和将图标堆叠在一起的功能。包含 Glyphicons 的 Bootstrap 3 没有太多选择,所以我从 font-awesome 中取出 CSS 并将其用于 Glyphicon。
HTML 看起来像:
<span class="glyphicon-stack">
<i class="glyphicon glyphicon-circle glyphicon-stack-2x"></i>
<i class="glyphicon glyphicon-plus glyphicon-stack glyphicon-stack-1x"></i>
</span>
主要的 CSS:
.glyphicon-stack {
position: relative;
display: inline-block;
width: 2em;
height: 2em;
line-height: 2em;
vertical-align: middle;
}
.glyphicon-circle{
position: relative;
border-radius: 50%;
width: 100%;
height: auto;
padding-top: 100%;
background: black;
}
.glyphicon-stack-1x {
line-height: inherit;
}
.glyphicon-stack-1x, .glyphicon-stack-2x {
position: absolute;
left: 0;
width: 100%;
text-align: center;
}
对于图标的样式(颜色、大小),您可以创建更多的 css 类属性并添加到相应的图标中。
看看这个example.
您可以向该元素添加一些简单的 css 规则,例如:
i {
background: green;
padding: 3px;
border-radius: 100%;
color: white;
}
你可以抽象它,创建两个类,比如 i.circle.green,然后在它们之间拆分这些规则,这样你就不会覆盖默认的引导类。
【讨论】:
尝试使用 .circle 类包装图标。
【讨论】:
如前所述,您可以这样做:
HTML
<div class='test'><span class="glyphicon glyphicon-plus"></span></div>
<span class="glyphicon-class">.glyphicon .glyphicon-plus</span>
CSS
.test{
width:25px;
height:25px;
background: green;
padding: 3px;
border-radius: 100%;
color: white;
text-align:center
}
【讨论】:
这可以通过以下方式在 Bootstrap 中本地完成:
<i class="d-flex justify-content-center align-items-center position-relative bi bi-circle lh-1" style="font-size: 15rem; color: cornflowerblue;">
<i style="font-size: 8rem;" class="position-absolute bi bi-card-checklist"></i>
</i>
【讨论】: