简体   繁体   English

Bootstrap内联表单堆栈彼此重叠

[英]Bootstrap inline form stack ontop of each other

I am having a problem, when this is shown full screen it looks how it is suppose too. 我有一个问题,当以全屏显示时,它看起来也应该是这样。 But as I start scaling down in size once I get to mobile the first form group exands the form all the way across and bumps down the second form group to a new line. 但是,当我开始移动时开始缩小尺寸时,第一个表单组将扩展整个范围,并将第二个表单组降低到新的一行。

I want both form groups in the same line even when I scale down to mobile view 即使缩小到移动视图,我也希望两个表单组在同一行中

         <div class = "container col-xs-12 col-sm-6 col-lg-5 center-block">
            <form class="form-inline">

             <div class="form-group">

                <label>Start:</label>
                <input type="text" class="form-control" placeholder="{{ start_length }}" id="bar">

             </div>
             <div class="form-group pull-right">

                <label>End: </label>
                <input type="text" class="form-control" placeholder="{{ end_length }}" id="bar1">

             </div>

            </form>
         </div>

jsfiddle jsfiddle

Maybe this use of media queries will give you what you want - or, at least, will point you at some possible direction: media queries这种使用也许会给您您想要的-至少会为您指明一些可能的方向:

See the fiddle here . 这里小提琴

css 的CSS

.center-block {float: none !important}
.inline{
display:inline-block!important;
width:auto!important;
}


@media only screen and (min-width : 320px) {
    input[type="text"] {
    width: 110px;
    background-color: yellow;
}       
}

/* Extra Small Devices, Phones */ 
@media only screen and (min-width : 480px) {
input[type="text"] {
width:110px;
background-color: red;
}

}

/* Small Devices, Tablets */
@media only screen and (min-width : 768px) {
input[type="text"] {
width: 110px;
background-color: blue;
}
}      
/* Medium Devices, Desktops */
@media only screen and (min-width : 992px) {
input[type="text"] {
width: 110px;
background-color: grey;
}
}

/* Large Devices, Wide Screens */
@media only screen and (min-width : 1200px) {
input[type="text"] {
width: 120px;
background-color: green;
}
}

html html

    <div class = "container col-xs-12 col-sm-8 col-lg-6 center-block">
        <form class="form-inline inline">

         <div class="form-group pull-left">

            <label>Start:</label>
            <input type="text" class="form-control" placeholder="{{ start_length }}" id="bar">

         </div>
         <div class="form-group pull-right">

            <label>End: </label>
            <input type="text" class="form-control" placeholder="{{ end_length }}" id="bar1">

         </div>

        </form>
     </div>

What you are describing is the default behavior of an inline form from bootstrap. 您所描述的是引导程序中内联表单的默认行为。 The reason is that mobile devices tend to be used in landscape mode and an inline form would be very small at that screen size. 原因是移动设备倾向于在横向模式下使用,并且在该屏幕尺寸下,内联表单将非常小。 As others have mentioned you will have to come up with your own solution to override the default behavior. 正如其他人提到的那样,您将不得不想出自己的解决方案来覆盖默认行为。 在此处输入图片说明

The Bootstrap documentation can be read here 可以在这里阅读Bootstrap文档

Is this what you are looking for? 这是你想要的? I've just specified that on a small screen, each input had to take half the space. 我刚刚指定在一个小屏幕上,每个输入必须占用一半的空间。

 <div class = "container col-xs-12 col-sm-6 col-lg-5 center-block">
        <form class="form-inline">

         <div class="form-group col-xs-6">

            <label>Start:</label>
            <input type="text" class="form-control" placeholder="{{ start_length }}" id="bar">

         </div>
         <div class="form-group pull-right col-xs-6">

            <label>End: </label>
            <input type="text" class="form-control" placeholder="{{ end_length }}" id="bar1">

         </div>

        </form>
     </div> 

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

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