简体   繁体   English

Bootstrap选项卡式表单未正确对齐

[英]Bootstrap tabbed forms not aligned properly

I want to have a form for each tab, but the form fields are completely misaligned: 我希望每个选项卡都有一个表单,但是表单字段完全未对齐:

http://jsfiddle.net/r2guf086/ http://jsfiddle.net/r2guf086/

As far as I can tell, I'm following Bootstrap's example code quite closely. 据我所知,我正在密切关注Bootstrap的示例代码 What is wrong here? 怎么了

My code: 我的代码:

<h2 id="ingredients"><strong>Ingredients</strong></h2>
<hr />
<div class="row">

<!-- Nav tabs -->
<div class="col-xs-12">
  <ul class="nav nav-tabs" role="tablist">
    <li class="active"><a href="#ingredients-1" role="tab" data-toggle="tab">#1</a></li>
    <li><a href="#ingredients-2" role="tab" data-toggle="tab">#2</a></li>
  </ul>
</div>

<!-- Tab panes -->
<div class="tab-content">
  <div class="tab-pane active" id="ingredients-1">
    <form class="form-horizontal" action='' method="POST">
      <fieldset>
        <div class="form-group">
          <div class="col-xs-12">
            <textarea name="product_ingredients" class="form-control" rows="10">xxx</textarea>
          </div>
        </div>
        <div class="form-group">
          <div class="col-md-2 col-md-offset-10">
            <button type="submit" class="btn btn-primary" form="update_product_ingredients_form">Save</button>
          </div>
        </div>
      </fieldset>
    </form>
  </div>
  <div class="tab-pane" id="ingredients-2">
    <form class="form-horizontal" action='' method="POST">
        <fieldset>
          <div class="form-group">
            <div class="col-xs-12">
              <textarea name="product_ingredients" class="form-control" rows="10">yyy</textarea>
            </div>
          </div>
          <div class="form-group">
            <div class="col-md-2 col-md-offset-10">
              <button type="submit" class="btn btn-primary" form="update_product_ingredients_form">Save</button>
            </div>
          </div>
        </fieldset>
      </form>
    </div>
  </div>

First one has the following CSS link: 第一个具有以下CSS链接:

<link class="cssdeck" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/css/bootstrap.min.css">

Second one has this CSS: 第二个有这个CSS:

<link class="cssdeck" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">

I would not mix and match CDNs for the same library, and only use those which you trust. 我不会为同一个库混用和匹配CDN,而只会使用您信任的CDN。 Change the CSS in the second example to this and it will work 将第二个示例中的CSS更改为此,它将起作用

<link class="cssdeck" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/css/bootstrap.min.css">

Before: http://jsfiddle.net/awkbmn0L/ 之前: http : //jsfiddle.net/awkbmn0L/

After: http://jsfiddle.net/1eznowf7/ 之后: http : //jsfiddle.net/1eznowf7/

(I've never heard of liveweave, and it was doing some weird display things to the code, so I went with jsfiddle for examples) (我从未听说过liveweave,它在代码中做了一些奇怪的显示,所以我以jsfiddle为例)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM