【问题标题】:Bootstrap 3, how disable auto-added Glyphicon?Bootstrap 3,如何禁用自动添加的 Glyphicon?
【发布时间】:2017-03-04 16:52:01
【问题描述】:

我在 Drupal 8 中使用 Bootstrap (v3)。当我创建一个名为“Search something”的按钮时,bootstrap 会自动添加一个“搜索”字形图标。我进行了一些网络搜索,但没有找到如何“禁用”(或隐藏?)按钮的“搜索”自动添加的字形图标。

当我从表单类自定义模块创建示例提交按钮时:

public function buildForm(array $form, FormStateInterface $form_state) {
...
$form['submit'] = [
  '#type' => 'button',
  '#value' => 'Search something',
];    

如果我转到有我的表单的页面,按钮会自动显示放大镜字形:

我想在没有任何字形图标的情况下显示我的按钮,我该怎么做?我必须为我的按钮添加一个类?哪个?

谢谢!

【问题讨论】:

  • 你能分享你的代码吗?据我所知,除非您不添加类 glyphicon glyphicon-search,否则按钮不会更改为 glyphicon 搜索。它是一个普通的按钮..
  • 我更新了我的代码的精简版 :)
  • 你能检查一下页面的html部分吗...

标签: drupal twitter-bootstrap-3


【解决方案1】:

这是“glyphicon glyphicon-search”的示例代码。检查添加到按钮的类,它不能自动添加 - 没有什么神奇的。

希望这会有所帮助..

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

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<p>normal button without Glyphicon icon: <span class="btn btn-default">button </span></p>

<p>Search icon: <span class="glyphicon glyphicon-search"></span></p>

<p>Search icon on a button:
  <button type="button" class="btn btn-default">
    <span class="glyphicon glyphicon-search"></span> Search
  </button>
</p>

<p>Search icon on a styled button:
  <button type="button" class="btn btn-info">
    <span class="glyphicon glyphicon-search"></span> Search
  </button>
</p>

【讨论】:

    【解决方案2】:

    我成功地将以下内容添加到我的表单元素中:

    '#icon' => array('none'),
    

    所以整个事情看起来像:

    $form['submit'] = [
      '#type' => 'button',
      '#value' => 'Search something',
      '#icon' => array('none'),
    ];    
    

    【讨论】:

      猜你喜欢
      • 2013-08-26
      • 1970-01-01
      • 2014-05-23
      • 2014-02-11
      • 2016-10-11
      • 2016-10-07
      • 2013-09-21
      相关资源
      最近更新 更多