twitter-bootstrap 如何在引导程序字形周围添加环
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33846244/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add a ring around bootstrap glyphicons
提问by George Edwards
How do you add a ring around bootstrap glyphs, without using a solid circle? I have seen an example where you just sit a glyph over the top of the circle glyph, but then you don't get the correct background colour, as shown below.
如何在不使用实心圆的情况下在 bootstrap 字形周围添加环?我看过一个例子,你只是在圆形字形的顶部放置一个字形,但是你没有得到正确的背景颜色,如下所示。
回答by vanburen
Here's an example of how to display and position an icon inside another (circle) div with modular background/color/border options.
这是一个示例,说明如何使用模块化背景/颜色/边框选项在另一个(圆形)div 中显示和定位图标。
See working Snippet.
请参阅工作代码段。
/**CSS FOR THE RING**/
.glyphicon-ring {
width: 60px;
height: 60px;
border-radius: 50%;
border: 4px solid white;
color: white;
display: inline-table;
text-align: center;
}
/**CSS FOR ICON WITH NO BACKGROUND COLOR**/
.glyphicon-ring .glyphicon-bordered {
font-size: 20px;
vertical-align: middle;
display: table-cell;
}
/**WITH AN ADDED BACKGROUND COLOR**/
.glyphicon-white {
background: white;
color: black;
border: 4px solid black;
}
.glyphicon-teal {
background: teal;
color: orange;
}
.glyphicon-red {
background: red;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<hr>
<div class="container-fluid text-center">
<div class="row">
<div class="col-sm-3">
<div class="alert alert-success">
<div class="glyphicon-ring"> <span class="glyphicon glyphicon-pencil glyphicon-bordered"></span>
</div>
</div>
<h4>Transparent Defaults</h4>
</div>
<div class="col-sm-3">
<div class="alert alert-warning">
<div class="glyphicon-ring glyphicon-white"> <span class="glyphicon glyphicon-pencil glyphicon-bordered"></span>
</div>
</div>
<h4>Background Color + Icon Color + Border Color</h4>
</div>
<div class="col-sm-3">
<div class="alert alert-danger">
<div class="glyphicon-ring glyphicon-red"> <span class="glyphicon glyphicon-pencil glyphicon-bordered"></span>
</div>
</div>
<h4>Background Color + Default Icon Color</h4>
</div>
<div class="col-sm-3">
<div class="alert alert-info">
<div class="glyphicon-ring glyphicon-teal"> <span class="glyphicon glyphicon-pencil glyphicon-bordered"></span>
</div>
</div>
<h4>Background Color + Icon Color</h4>
</div>
</div>
</div>
<hr>
回答by Donnie D'Amato
I'd use border-radius, you'll probably need to tweak the heightand widthvalues.
我会使用border-radius,您可能需要调整height和width值。
.glyph{
height:2em;
width:2em;
border-radius:50%;
border:3px solid #fff;
}


