Display two fields side by side in a Bootstrap Form

前端 未结 8 926
执笔经年
执笔经年 2020-12-23 12:52

I am trying to display a year range input on a form that has a 2 textboxes. One for the min and one for the max and are separated by a dash.

I want this all on the

相关标签:
8条回答
  • 2020-12-23 13:51

    How about using an input group to style it on the same line?

    Here's the final HTML to use:

    <div class="input-group">
        <input type="text" class="form-control" placeholder="Start"/>
        <span class="input-group-addon">-</span>
        <input type="text" class="form-control" placeholder="End"/>
    </div>
    

    Which will look like this:

    screenshot

    Here's a Stack Snippet Demo:

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.css" rel="stylesheet"/>
    
    <div class="input-group">
        <input type="text" class="form-control" placeholder="Start"/>
        <span class="input-group-addon">-</span>
        <input type="text" class="form-control" placeholder="End"/>
    </div>

    I'll leave it as an exercise to the reader to translate it into an asp:textbox element

    0 讨论(0)
  • 2020-12-23 13:58

    For Bootstrap 4

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
    
    <div class="input-group">
        <input type="text" class="form-control" placeholder="Start"/>
        <div class="input-group-prepend">
            <span class="input-group-text" id="">-</span>
        </div>
        <input type="text" class="form-control" placeholder="End"/>
    </div>

    0 讨论(0)
提交回复
热议问题