简体   繁体   English

如何使用CSS包装Font-Awesome?

[英]How to wrap Font-Awesome with CSS?

I am using bootstrap & font awesome, and i am looking to make something like this: 我正在使用bootstrap和字体真棒,我希望做这样的事情:

I have this: 我有这个: 我有的

I want something like this: 我想要这样的东西: 我想要的是

Markup: 标记:

<div class="alert alert-success"><i class="fa fa-paperclip icon-alert"></i> Everything was edited!</div>

CSS: CSS:

.icon-alert {
  font-size: 30px;
  float: left;
  margin-right: 10px;
  opacity: 0.7;
}

You'll need to set a height to the container and then you can hide the overflow of the nested font-awesome icon, using overflow:hidden . 你需要为容器设置一个高度,然后你可以使用overflow:hidden嵌套字体 - awesome图标的overflow:hidden

CSS : CSS

.clipped-alert{
  overflow:hidden;
  height:55px;
}

HTML : HTML

<div class="clipped-alert alert alert-success">
    <i class="fa fa-paperclip fa-5x icon-alert pull-right text-success"></i> 
    Everything was edited!
</div>


DEMO DEMO

You would create a container around the icon that has the property of over-flow: hidden; 您将在图标周围创建一个具有over-flow: hidden;属性的容器over-flow: hidden; You can then position the element inside however you want. 然后,您可以根据需要将元素放置在内部。

http://jsfiddle.net/MathiasaurusRex/W9WC2/1/ http://jsfiddle.net/MathiasaurusRex/W9WC2/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM