在bootstrap标志符号图标上单击弹出窗口

时间:2017-03-07 14:08:47

标签: css twitter-bootstrap

我按照教程https://www.w3schools.com/bootstrap/bootstrap_modal.asp

进行了操作

但是想用字形图标这样做:

@button-disable: #aea79f;
@title-card: font-size:36px, font-weight:lighter, line-height:29px, color:@button-disable;

不起作用吗?有可能吗?

4 个答案:

答案 0 :(得分:2)

您可以将其设置为我的代码,然后“点击”字形应该打开模态。您的代码存在问题,因为您无法将“类”添加两次到一个元素。

<span class="glyphicon glyphicon-pencil" data-toggle="modal" data-target="#myModal"></span>

答案 1 :(得分:2)

    <a href="#myModal" data-toggle="modal" data-target="#myModal"><span class="glyphicon glyphicon-pencil"></span></a>

对你的span标签进行一次行动呼吁(即.href,按钮),它会起作用。

答案 2 :(得分: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>
  
  
  <div class="container">
  <h2>Modal Example</h2>
  <!-- Trigger the modal with a button -->
  <span class="glyphicon glyphicon-pencil" data-toggle="modal" data-target="#myModal"></span>

  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
          <p>Some text in the modal.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
      
    </div>
  </div>
  
</div>

答案 3 :(得分:1)

您可以将glyphicon放在按钮上:

<button class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">
<span class="glyphicon glyphicon-pencil"></span>
</button>