如何在文本旁边放置图标?

时间:2015-05-19 22:20:49

标签: css html5 twitter-bootstrap font-awesome

我很难在标题和段落旁边找到一个字体很棒的图标,如下图所示:

Example of What I Want

我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:0)

您可以这样做:

<强> HTML

 <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
  <link href='http://fonts.googleapis.com/css?family=Roboto:400,500' rel='stylesheet' type='text/css'>
   <div id="contenedor">
      <div class="left">
        <h2>Nice Work</h2>
        <p>We possess within us two</p>
        <p>winds. So far I have written</p>
        <p>only of the conscious mind.</p>
      </div>
      <div class="right">
        <i class="fa fa-search"></i>
      </div>
   </div>

<强> CSS

  #contenedor {
    font-family: 'Roboto', sans-serif;
    width: 500px;
    height: 500px;
    background: #FFF;
    float: left;
    display: block;
  }
  .left {
    float: left;
    margin-right: 20px;
    text-align: right;
  }
  .left h2 {
    font-weight: bold;
  }
  .left p {
    line-height: 18px;
    color:#BDC3C7;
  }
  .right {
    padding-top: 20px;
  }
  .right i {
    background: #1DCFD1;
    padding: 20px;
    border-radius: 30px;
    color:#FFF;
  }

<强> Working Demo