Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Place Two Input Fields Side-by-Side

I've been trying to place two input fields side-by-side for sometime now and and I can't get them to actually get inline. Here's my HTML:

<div class="container">
    <div class="form-group name1 col-md-6">
        <label for="exampleInputEmail1" class="formText">FIRST NAME:*</label>
        <input type="text" class="form-control" id="name" aria-describedby="emailHelp" name="muverName">
    </div>

    <div class="form-group name2 col-md-6">
        <label for="exampleInputEmail1" class="formText">LAST NAME:*</label>
        <input type="text" class="form-control" id="name" aria-describedby="emailHelp" name="muverPhone">
    </div>
</div>

I'm trying to utilize Bootstrap as well, but I can't for the life of me get them to align side-by-side. Here's the corresponding CSS:

.name1 {
    float: left;
}   

.name2 {
    float: right;
}

#name {
    width: 223.67px;
    height: 40.25px;
}

.form-group {
    margin-left: 5%;
    margin-right: 5%;
}

.containerr {
    display: inline-block;
}

This is my output:

enter image description here

Whats the best way to place them side-by-side?

like image 705
mur7ay Avatar asked Aug 05 '16 15:08

mur7ay


1 Answers

Bootstrap should do this for you. Looks like you're missing the <div class="row"> around your columns:

<div class="container">
    <div class="row">
        <div class="form-group name1 col-md-6">
            <label for="exampleInputEmail1" class="formText">FIRST NAME:*</label>
            <input type="text" class="form-control" id="name" aria-describedby="emailHelp" name="muverName">
        </div>

        <div class="form-group name2 col-md-6">
            <label for="exampleInputEmail1## Heading ##" class="formText">LAST NAME:*</label>
            <input type="text" class="form-control" id="name" aria-describedby="emailHelp" name="muverPhone">
        </div>
    </div>
</div>
like image 155
Nick Bull Avatar answered Nov 15 '22 05:11

Nick Bull