【问题标题】:Glyphicon inside button not visible按钮内的字形图标不可见
【发布时间】:2017-03-28 17:09:08
【问题描述】:

我想将 glyphicon 放在按钮内。我不知道为什么它不可见。唯一可见的是文本,而不是字形图标。

Here 是示例。这个按钮有问题:

<button type="button" class="btn btn-primary">
<span class="glyphicon glyphicon-arrow-up"></span>3</button>

【问题讨论】:

  • 您的代码在我的网站上运行良好。确保包含正确的引导 css 文件。
  • 从 codepen 示例中您可以看到 glyphicon?
  • 我认为您没有导入引导库。
  • 我已经添加了引导程序,但版本为 4.0 alpha。当我将其更改为 3.3.7 时,一切都很好。

标签: twitter-bootstrap glyphicons


【解决方案1】:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<button type="button" class="btn btn-primary">
<span class="glyphicon glyphicon-arrow-up"></span> 3 </button>

【讨论】:

  • 我猜问题出在 codepen 链接上。它指向 bootstrap 4.0 alpha。当我将链接更改为 3.3.7 版本后,一切都开始正常工作了。
  • 可能是你应该包含引导 cdn 或下载它
【解决方案2】:

使用w3schools 的工作示例

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>Glyphicon Examples</h2>
 
    <button type="button" class="btn btn-primary">
      <span class="glyphicon glyphicon-arrow-up"></span> 3
    </button>
  
</div>

</body>
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-08
    • 1970-01-01
    • 1970-01-01
    • 2015-06-21
    • 2015-08-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多