Bootstrap popover太窄了

时间:2015-11-10 15:45:49

标签: html twitter-bootstrap twitter-bootstrap-3 popover

http://jsfiddle.net/0y8oy7gf/2/

我有一个Bootstrap 3表单,其中有一个位于第一个文本输入右侧的弹出窗口。弹出窗口在该输入的焦点上触发,并且触发器正常工作。我的问题是我希望popover更宽,以便我可以有更长的文本行,但它似乎包含在父.col-xs-6中。是否有任何方法可以让.container-fluid包含它,以便它可以占据右边的空白区域?

HTML在下面,上面的jsfiddle演示了这个问题。谢谢!

  <div class="container-fluid"> 
   <div class="row">
     <div class="col-12">
      <div class="row">
        <div class="col-xs-6 col-xs-offset-3 panel panel-gray floating"> 
          <div class="panel-body">
            <form action="?" method="POST" id="foo">
              <div class="form-group">
                <h3>Set your new password</h2>
              </div>
              <div class="form-group form-group-lg">
                <label for="new-password">New password</label>
                <input type="password" class="form-control" id="new-password" autofocus data-toggle="popover" data-content="8-20 characters long" data-trigger="focus" data-placement="right" viewport="container">
              </div>
              <div class="form-group form-group-lg">
                <label for="confirm-new-password">Confirm new password</label>
                <input type="password" class="form-control" id="confirm-new-password">
              </div>
              <div class="form-group form-group-lg">
                <label for="security-answer">Answer your security question:</label>
                <p id="security-question">How many cups of sugar does it take to get to the moon?</p>
                <input type="text" class="form-control" id="security-answer">
              </div>
              <div class="btn-group-lg">
                <input type="submit" value="Change password" class="btn btn-primary btn-block" id="btn_changePassword">
              </div>
            </form>
            <br>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

1 个答案:

答案 0 :(得分:2)

您只需设置data-container属性即可告诉popover要使用哪个元素,因为它包含元素(请参阅documentation):

  <div class="container-fluid"> 
   <div class="row">
     <div class="col-12">
      <div class="row">
        <div class="col-xs-6 col-xs-offset-3 panel panel-gray floating"> 
          <div class="panel-body">
            <form action="?" method="POST" id="foo">
              <div class="form-group">
                <h3>Set your new password</h2>
              </div>
              <div class="form-group form-group-lg">
                <label for="new-password">New password</label>
                <input type="password" class="form-control" id="new-password" autofocus data-toggle="popover" data-container=".container-fluid" data-content="8-20 characters long" data-trigger="focus" data-placement="right" viewport="container">
              </div>
              <div class="form-group form-group-lg">
                <label for="confirm-new-password">Confirm new password</label>
                <input type="password" class="form-control" id="confirm-new-password">
              </div>
              <div class="form-group form-group-lg">
                <label for="security-answer">Answer your security question:</label>
                <p id="security-question">How many cups of sugar does it take to get to the moon?</p>
                <input type="text" class="form-control" id="security-answer">
              </div>
              <div class="btn-group-lg">
                <input type="submit" value="Change password" class="btn btn-primary btn-block" id="btn_changePassword">
              </div>
            </form>
            <br>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

http://jsfiddle.net/0y8oy7gf/3/