CSS 如何在引导程序面板的右侧创建图标?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31240167/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 11:20:35  来源:igfitidea点击:

How to create an icon on the right side of a bootstrap panel?

csstwitter-bootstraptwitter-bootstrap-3frontendfont-awesome

提问by Mincong Huang

I got a problem positionning an awesome iconon a bootstrap panel. I want to put this icon on the right side of the panel heading. But the code doesn't work. Can somebody help ?

我在引导面板上定位一个很棒的图标时遇到问题。我想把这个图标放在面板标题的右侧。但是代码不起作用。有人可以帮忙吗?

<div class="panel panel-primary">
    <div class="panel-heading">
        Title
        <i class="fa fa-question-circle text-right"></i>
    </div>
    <div class="panel-body">
        Hello world!
    </div>
</div>

If you need to preview the result, check here : http://jsfiddle.net/7q7w0n76/

如果您需要预览结果,请在此处查看:http: //jsfiddle.net/7q7w0n76/

回答by Alberto I.N.J.

Try to change text-rightto pull-rightin the fa fa-question-circleclass.

尝试在课堂上更改text-right为。pull-rightfa fa-question-circle

E.g.

例如

<i class="fa fa-question-circle pull-right"></i>

Here's the JsFiddle Link.

这是JsFiddle 链接

Hope it helps.

希望能帮助到你。

回答by odedta

Add this to your CSS file:

将此添加到您的 CSS 文件中:

.text-right {
    float: right;
}

If you're using bootstrap, adding class pull-rightmight do the trick as well.

如果您正在使用引导程序,添加类pull-right也可以解决问题。

One last thing, if you're adding FontAwesome icons and you write semantic HTML then use <span>tags for it instead of <i>tags (explanation).

最后一件事,如果您要添加 FontAwesome 图标并编写语义 HTML,则使用<span>标签代替<i>标签(解释)。