简体   繁体   English

如何将输入框旁边的按钮对齐?

[英]How can I align the button right next to the input box?

<div class="row">
    @Html.LabelFor(m => m.ClientVideoFilePath)
    <form>
        <div class="input-group">
            @Html.TextBoxFor(m => m.ClientVideoFilePath, new { @class = "form-control large-textbox" })
            <span class="input-group-btn">
                <button class="btn btn-default">Upload Video</button>
            </span>
        </div>
    </form>
</div>

I don't understand why my code is giving me weird results. 我不明白为什么我的代码给我奇怪的结果。 It's showing me a button that is shot way to right of my input box. 它向我显示了一个按钮,该按钮位于我的输入框右侧。 I want the button right next to it! 我想要旁边的按钮! FML

Also here is the contents of the large-textbox class: 这也是large-textbox类的内容:

.large-textbox {
    width: 100% !important;
}

In bootstrap element which has row (it uses negative margin - v.3.3 and flexbox in v.4+) class always must be followed by element with column class eg 在具有行的 bootstrap元素中(使用负边距-v.3.3和v.4 +中的flexbox),类始终必须紧跟具有列类的元素,例如

<div class="row">
   <div class="col-md-12"></div>
   ...and/or...
   <div class="col-md-6"></div>
   <div class="col-md-6"></div>
</div>

You can either remove the row class or add col* class right after it. 您可以删除类,也可以在其后添加col *类。 Also you don't need this style 你也不需要这种风格

.large-textbox {
    width: 100% !important;
}

Edit: Also if you are using bootstrap 4 rename input-group-btn to input-group-append 编辑:同样,如果您正在使用引导程序4重命名input-group-btninput-group-append

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

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