在文本之前显示字体真棒图标

时间:2016-04-16 10:24:03

标签: html twitter-bootstrap font-awesome

我想在单词“Like”之前添加一个类似的图标/按钮,我尝试了字体很棒但是“i”标签只会在Italic中显示“Like”文本。虽然这个片段在这里工作,但是当我在我的编辑器上编写它时它不起作用,我用IE和Chrome都试过它,但仍然无法正常工作

这是我用于CDN的链接:

<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>

这是HTML代码:

<div class="row">
    <div class="col-xs-4"><button class="btn btn-block btn-primary"><i class="fa  fa-thumbs-up">Like</i></button></div>
    <div class="col-xs-4"><button class="btn btn-block btn-info">Info</button></div>
    <div class="col-xs-4"><button class="btn btn-block btn-danger">Delete</button></div>

</div> 

演示:

h2 {
  font-family: Lobster, Monospace;
}

.thick-green-border {
  border-color: green;
  border-width: 10px;
  border-style: solid;
  border-radius: 50%;
}
<div class="fluid-container">

  <div class="row">

    <div class="col-md-8">
      <h2 class="red-text text-center">CatPhotoApp</h2>
    </div>

    <div class="col-md-4">
      <a href="https://www.google.co.uk/?gws_rd=ssl"><img class="img-responsive thick-green-border" src="https://s3.amazonaws.com/freecodecamp/relaxing-cat.jpg"></a>
    </div>

  </div>



  <img src="https://s3.amazonaws.com/freecodecamp/running-cats.jpg" class="img-responsive">


  <div class="row">
    <div class="col-xs-4"><button class="btn btn-block btn-primary"><i class="fa fa-thumbs-up">Like</i></button></div>
    <div class="col-xs-4"><button class="btn btn-block btn-info">Info</button></div>
    <div class="col-xs-4"><button class="btn btn-block btn-danger">Delete</button></div>

  </div>


  <p>Things cats <span class="text-danger">love</span>:</p>
  <ul>
    <li>cat nip</li>
    <li>laser pointers</li>
    <li>lasagna</li>
  </ul>
  <p>Top 3 things cats hate:</p>
  <ol>
    <li>flea treatment</li>
    <li>thunder</li>
    <li>other cats</li>
  </ol>
  <form action="/submit-cat-photo">
    <label><input type="radio" name="indoor-outdoor"> Indoor</label>
    <label><input type="radio" name="indoor-outdoor"> Outdoor</label>
    <label><input type="checkbox" name="personality"> Loving</label>
    <label><input type="checkbox" name="personality"> Lazy</label>
    <label><input type="checkbox" name="personality"> Crazy</label>
    <input type="text" placeholder="cat photo URL" required>
    <button type="submit">Submit</button>
  </form>

1 个答案:

答案 0 :(得分:2)

您需要打开此页面,而不是我假设您在本地执行的file:///...

您的CDN未指定协议:href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"因此它从页面容器中获取。如果您以file:///打开页面,它会尝试查找不存在的file:///maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css

如果您仍想让它在文件中运行,请更改:

  

HREF = “// maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css”

  

HREF = “http://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css”