简体   繁体   English

为什么默认情况下我的表单位于我的引导模式col-md-6中?

[英]Why is my form inside my bootstrap modal col-md-6 by default?

I'm building a website and tried to embed a form as a partial view inside a modal window. 我正在建立一个网站,并尝试将表单作为部分视图嵌入到模式窗口中。 I succeeded in getting the form inside the modal, but it only appears on the left half of the modal body. 我成功地将表单获取到模态内部,但它仅出现在模态主体的左半部分。 Does anyone know a fix for this? 有人知道解决办法吗?

I never set the col-md-6 anywhere so there i no reason for it to appear this way. 我从来没有在任何地方设置col-md-6,所以我没有理由让它以这种方式出现。 I even tried to exactly copy some modal examples from the internet that appeared to be correct, but i had the same problem. 我什至试图从互联网上准确复制一些模态示例,这些示例似乎是正确的,但是我也遇到了同样的问题。

Modal window that the form is loaded in : 表单加载的模态窗口

<!-- Modal -->
<div id="addLeverancierModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title">Leverancier toevoegen</h4>
        </div>
        <div class="modal-body">
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Annuleer</button>
            <button type="button" class="btn btn-success">Opslaan</button>
        </div>
    </div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->

Modal form(partial view) : 模态形式(局部视图)

<form role="form">
<div class="form-group">
    <label>Leveranciernummer</label>
    <input type="email" class="form-control" id="leveranciernummerInput" placeholder="Leveranciernumer">
</div>
<div class="form-group">
    <label>Naam</label>
    <input class="form-control" id="leveranciernaamInput" placeholder="Naam">
</div>
<div class="form-group">
    <label>Straatnaam</label>
    <input class="form-control" id="straatnaamInput" placeholder="Straatnaam">
</div>
<div class="form-group">
    <label>Huisnummer</label>
    <input class="form-control" id="huisernummerInput" placeholder="Huisnummer">
</div>
<div class="form-group">
    <label>Postcode</label>
    <input class="form-control" id="postcodeInput" placeholder="Postcode">
</div>
<div class="form-group">
    <label>Plaatsnaam</label>
    <input class="form-control" id="plaatsnaamInput" placeholder="Plaatsnaam">
</div>
<div class="form-group">
    <label>Land</label>
    <input class="form-control" id="landInput" placeholder="Land">
</div>
<div class="form-group">
    <label>VAT</label>
    <input class="form-control" id="vatInput" placeholder="VAT">
</div>
<div class="form-group">
    <label>Telefoon</label>
    <input class="form-control" id="telefoonInput" placeholder="Telefoon">
</div>
<div class="form-group">
    <label>Email</label>
    <input class="form-control" id="emailInput" placeholder="Email">
</div>
<div class="form-group">
    <label>Email extra</label>
    <input class="form-control" id="emailExtraInput" placeholder="Email extra">
</div>
</form>

JQuery to load form inside modal: jQuery加载模态内的表单:

var GetLeverancierForm = function () {
$.ajax({
    type: "GET",
    url: baseURL + '/AddLeverancier',
    success: function (data) {
        $(".modal-body").html(data);
    }
});
}

Base container all content is loaded in(all html files): 基本容器中的所有内容均已加载(所有html文件):

    <div class="container body-content">
    @RenderBody()
    </div>

Picture of how the modal appears: 模态显示的图片: 我的模态只在左边有内容

Design your form like this 像这样设计表单

<form class="form-horizontal">
    <div class="form-group">
      <label class="control-label col-sm-2" for="email">Email:</label>
      <div class="col-sm-10">
        <input type="email" class="form-control" id="email" placeholder="Enter email">
      </div>
    </div>
    <div class="form-group">
      <label class="control-label col-sm-2" for="pwd">Password:</label>
      <div class="col-sm-10">          
        <input type="password" class="form-control" id="pwd" placeholder="Enter password">
      </div>
    </div>
  </form>

It would look like this : 它看起来像这样:

在此处输入图片说明

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

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