【问题标题】:How to position an icon alongside text?如何在文本旁边放置图标?
【发布时间】:2015-05-28 04:38:29
【问题描述】:

我正在努力在标题和段落旁边获得一个很棒的字体图标,如下图所示:

我怎样才能做到这一点?

【问题讨论】:

  • 欢迎来到 SO!请说明您的尝试。

标签: css html twitter-bootstrap font-awesome


【解决方案1】:

你可以这样做:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-22
    • 2021-07-20
    • 1970-01-01
    • 2016-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多