twitter-bootstrap CSS 引导程序:将图标添加到 h1
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18567098/
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
CSS bootstrap: add icon to h1
提问by B.B King
i add icon(Bootstrap Glyphicons) in h1but iconnot in text baseline. how to fix This?!
我在文本中添加图标(Bootstrap Glyphicons)h1但icon不在文本中baseline。如何解决这个问题?!
Code:
代码:
<h1 ><a><i class="icon-play"></i>TEST TEXT</a></h1>
回答by Girish Thimmegowda
回答by user3460493
Im using Bootstrap v3.2 and I had the same problem.
我使用 Bootstrap v3.2,我遇到了同样的问题。
<h3><span class="glyphicon glyphicon-user"></span> User</h3>
<h3><span class="glyphicon glyphicon-user"></span> User</h3>
so I changed the display property of the glyphicon from inline-block to inline.
所以我将字形的显示属性从 inline-block 更改为 inline。
.glyphicon
{position: relative;
top: 1px;
display: inline;
...
}
This is due the An inline element has no line break before or after it, and it tolerates HTML elements next to it but an inline-block element is placed as an inline element (on the same line as adjacent content), but it behaves as a block element.
这是因为内联元素之前或之后都没有换行符,并且它容忍旁边的 HTML 元素,但内联块元素被放置为内联元素(与相邻内容在同一行),但它的行为与块元素。
回答by Artur Fidelus
I would try:
我会尝试:
1) changing padding of i.icon-play
1) 改变 i.icon-play 的填充
2) background-position of i.icon-play
2) i.icon-play 的背景位置
3) vertical-align:center; line-height:12px; of i.icon-play
3) 垂直对齐:居中;行高:12px;i.icon-play
One of those will work, good luck ;-)
其中之一会起作用,祝你好运;-)

