Bootstrap 3 make columns of a raw all the same height - html

I have a row and 2 columns in there which I am trying to make the same height as there are border lines top and bottom that should be alined, also box shadow.
I've tried tons of recommended solutions recommended here excluding the ones involving javascript, How can I make Bootstrap columns all the same height? and none worked. E.g. adding this CSS to the row class didn't work:
.equal {
display: flex;
display: -webkit-flex;
flex-wrap: wrap;
}
My CSS:
.contact .info {
padding: 30px;
background: #fff;
box-shadow: 0 0 24px 0 rgba(0, 0, 0, 0.1);
margin-bottom: 40px;
}
.contact .php-email-form {
padding: 30px;
background: #fff;
box-shadow: 0 0 24px 0 rgba(0, 0, 0, 0.1);
margin-bottom: 40px;
}
<section id="contact" class="contact">
<div class="container">
<div class="section-title">
<h2>CONTACT</h2>
</div>
<div class="row">
<div class="col-md-5">
<div class="info">
<div class="email">
<i class="bi bi-envelope"></i>
<h4>Email:</h4>
<p>email</p>
</div>
<div class="phone">
<i class="bi bi-phone"></i>
<h4>Telephone:</h4>
<p>95 966 0</p>
</div>
<div class="address">
<i class="bi bi-geo-alt"></i>
<h4>Messenger:</h4>
<p>address</p>
</div>
<div class="phone">
<i class="bi bi-phone"></i>
<h4>Whatsapp:</h4>
<p>745 2720</p>
</div>
<div class="phone">
<i class="bi bi-phone"></i>
<h4>Telegram:</h4>
<p>745 2720</p>
</div>
</div>
</div>
<div class="col-md-7">
<form action="forms/contact.php" method="post" role="form" class="php-email-form">
<div class="row">
<div class="form-group col-md-6">
<label for="name">N</label>
<input type="text" name="name" class="form-control" id="name" required>
</div>
<div class="form-group col-md-6">
<label for="name">Email</label>
<input type="email" class="form-control" name="email" id="email" required>
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<label for="name">Mobile</label>
<input type="text" class="form-control" name="subject" id="subject" required>
</div>
<div class="form-group col-md-6">
<label for="name">F</label>
<input type="text" class="form-control" name="subject" id="subject" required>
</div>
</div>
<div class="form-group">
<label for="name">T</label>
<input type="text" class="form-control" name="subject" id="subject" required>
</div>
<div class="form-group">
<label for="name">U</label>
<textarea class="form-control" name="message" rows="6" required></textarea>
</div>
<div class="err">
<div class="processing">Loading</div>
<div class="error-message"></div>
<div class="sent-message">Your message has been sent.!</div>
</div>
<div class="text-center"><button type="submit">Send</button></div>
</form>
</div>
</div>
</div>
</section>

You have to be very specific with your css.
I added a border to your cols so you have a visual of the col height.
BS3 was not designed to work with flex, but that doesn't mean it can't.
Update:
Created 2 css classes .d-flex, and .d-flex-item
In CSS flex model display:flex items make their children flex items which by default stretch to fit their container's height.
This goes only one level deep so to make this work with your layout:
div.row is a flex container
div.col-md-5:
is a flex item of its parent: div.row
is a flex container to its child div.info
div.info is a flex item of its parent: div.col-md-5
div.col-md-7 is a flex item of its parent: div.row
All of this is to allow the flex items to stretch to their parent containers. Setting a CSS height on any flex-item will override the default stretch for that item.
/* No changes here to your css */
.contact .info {
padding: 30px;
background: #fff;
box-shadow: 0 0 24px 0 rgba(0, 0, 0, 0.1);
margin-bottom: 40px;
}
.contact .php-email-form {
padding: 30px;
background: #fff;
box-shadow: 0 0 24px 0 rgba(0, 0, 0, 0.1);
margin-bottom: 40px;
}
/* flex css, see your HTML class attribute */
.d-flex {
display: flex;
}
.d-flex-item {
flex: 1 0 auto;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons#1.9.1/font/bootstrap-icons.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#3.4.1/dist/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/jquery#3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#3.4.1/dist/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
<section id="contact" class="contact">
<div class="container">
<div class="section-title">
<h2>CONTACT</h2>
</div>
<div class="row d-flex">
<div class="col-md-5 d-flex-item d-flex">
<div class="info d-flex-item">
<div class="email">
<i class="bi bi-envelope"></i>
<h4>Email:</h4>
<p>email</p>
</div>
<div class="phone">
<i class="bi bi-phone"></i>
<h4>Telephone:</h4>
<p>95 966 0</p>
</div>
<div class="address">
<i class="bi bi-geo-alt"></i>
<h4>Messenger:</h4>
<p>address</p>
</div>
<div class="phone">
<i class="bi bi-phone"></i>
<h4>Whatsapp:</h4>
<p>745 2720</p>
</div>
<div class="phone">
<i class="bi bi-phone"></i>
<h4>Telegram:</h4>
<p>745 2720</p>
</div>
</div>
</div>
<div class="col-md-7 d-flex-item">
<form action="forms/contact.php" method="post" role="form" class="php-email-form">
<div class="row">
<div class="form-group col-md-6">
<label for="name">N</label>
<input type="text" name="name" class="form-control" id="name" required>
</div>
<div class="form-group col-md-6">
<label for="name">Email</label>
<input type="email" class="form-control" name="email" id="email" required>
</div>
<div class="form-group col-md-6">
<label for="name">Mobile</label>
<input type="text" class="form-control" name="subject" id="subject" required>
</div>
<div class="form-group col-md-6">
<label for="name">F</label>
<input type="text" class="form-control" name="subject" id="subject" required>
</div>
<div class="form-group col-md-6">
<label for="name">T</label>
<input type="text" class="form-control" name="subject" id="subject" required>
</div>
<div class="form-group col-md-6">
<label for="name">U</label>
<textarea class="form-control" name="message" rows="6" required></textarea>
</div>
<div class="err">
<div class="processing">Loading</div>
<div class="error-message"></div>
<div class="sent-message">Your message has been sent.!</div>
<div class="text-center"><button type="submit">Send</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</section>

Related

Do not put the label inline in a form-inline - Bootstrap

I have a form, I have in this two fields inline because they are in a form-inline div, I want to put the label of these above the fields and not next to them. How to remove form-inline from them without affecting the fields?
Here is a CodePen
<main id="contact_part">
<article class="mb-5 row">
<h1>Nous Contacter</h1>
<div class="col-md-12">
<form action="" method="post" id="contact_form">
<div class="form-inline">
<label class="" for="name_contact">Name</label>
<input type="text" class="form-control mb-2 mr-sm-2" id="name_contact" placeholder="Nom" required>
<label class="" for="lastNameContact">Name</label>
<input type="text" class="form-control mb-2 mr-sm-2" id="lastName_contact" placeholder="Prénom" required>
</div>
<div class="form-group">
<label class="" for="email_contact">E-Mail</label>
<input type="email" name="email_contact" id="email_contact" class="form-control" placeholder="E-Mail" required>
</div>
<div class="form-group">
<label class="" for="message_contact">Message</label>
<textarea class="form-control" id="message_contact" placeholder="Message" required></textarea>
</div>
</form>
</div>
</article>
</main>
#contact_part article {
background-color: #FFF989;
font-family: main, "Palatino Linotype", "Book Antiqua", Palatino, serif;
color: #565656;
padding: 50px;
}
#contact_part .row {
display: block;
}
#contact_part h1 {
font-size: 1.7rem;
text-transform: uppercase;
margin-bottom: 3rem;
text-decoration: underline;
text-align: center;
}
#contact_form {
width: 50%;
margin: 0 auto;
}
#contact_form .form-inline label {
}
#contact_form input, #contact_form textarea {
border: none;
border-bottom: 1px solid #C6C6C6;
background-color: #FFF989;
}
If I understand correctly you no need to use form-inline class instead use like below code. Your form will look good.
<main id="contact_part">
<div class="container">
<article class="mb-5 row">
<div class="col-12">
<h1>Nous Contacter</h1>
</div>
<div class="col-12">
<form action="" method="post" id="contact_form">
<div class="row">
<div class="col-12 col-md-6">
<div class="form-group">
<label class="custom-control pl-0" for="name_contact">First Name</label>
<input type="text" class="form-control" id="name_contact" placeholder="First Name" required>
</div>
</div>
<div class="col-12 col-md-6">
<div class="form-group">
<label class="custom-control pl-0" for="lastNameContact">Last Name</label>
<input type="text" class="form-control" id="lastName_contact" placeholder="Last Name" required>
</div>
</div>
<div class="col-12">
<div class="form-group">
<label class="custom-control pl-0" for="email_contact">E-Mail</label>
<input type="email" name="email_contact" id="email_contact" class="form-control" placeholder="example#example.com" required>
</div>
</div>
<div class="col-12">
<div class="form-group">
<label class="custom-control pl-0" for="message_contact">Message</label>
<textarea class="form-control" id="message_contact" placeholder="Message" rows="5" required></textarea>
</div>
</div>
</div>
</form>
</div>
</article>
</div>
</main>
Code Pen.
Use col-12 instead of col-md-12 class for better performance. Don't use row without container or container-fluid. If you use only row it give you horizontal scroll bar. Your code will look like this.
<div class="container">
<div class="row">
<div class="col-12"></div>
</div>
</div>
Or
<div class="container-fluid">
<div class="row">
<div class="container">
<div class="row">
<div class="col-12"></div>
</div>
</div>
</div>
</div>
Fluid view or 100% Browser width
<div class="container-fluid">
<div class="row">
<div class="col-12">Content</div>
<div class="col-12">Content</div>
<div class="col-12">Content</div>
<div class="col-12">Content</div>
</div>
</div>
Hope this help!
Here you go, let me know if this works: https://codepen.io/luke-richter/pen/XWJVqWO
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
#contact_part{
background-color: #FFF989;
font-family: main, "Palatino Linotype", "Book Antiqua", Palatino, serif;
color: #565656;
padding: 50px;
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<!------ Include the above in your HEAD tag ---------->
<main id="contact_part">
<div class="container ">
<div class="row">
<h2>Inline form with heading above inputs</h2>
</div>
<form action="#">
<div class="row">
<div class="col-md-3">
<div class="form-group form-group-sm">
<label for="firstname" class="control-label">Firstname1</label>
<input type="text" class="form-control" id="firstname" placeholder="Firstname">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="lastname" class="control-label">Last Name2</label>
<input type="text" class="form-control" id="lastname" placeholder="Last Name">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="lastname" class="control-label">Last Name3</label>
<input type="text" class="form-control" id="lastname" placeholder="Last Name">
</div>
</div>
</div>
<div class="row">
<div class="col-xs-3">
<textarea class="form-control"></textarea>
</div>
</div>
<div class="row">
<div class="col-xs-3"><br>
<button type="submit" class="btn btn-default">Submit</button>
</div>
</div>
</form>
</div>
</div>
Try this,
.form-inline label
{
margin-bottom:3em;
}
Or You can move the label outside the<div class="form-inline">

HTML -Card text not wrapping

I created a html card following this tutorial. Then i added to my page (which uses bootstrap 3.0). However, the text is not wrappering like it does in the tutorial. Does anyone know why this is or how to fix this?
Picture
https://i.stack.imgur.com/cD9dy.png
Html snippet
<div class="row">
<div class="col-lg-2">
<div class="form-group ">
<card [visable]="obj.one" [width]="100" [image]="obj.two" [header]="project.manager?.name" [content]="obj.four"></card>
</div>
</div>
<div class="col-lg-3">
<div class="form-group">
<label class="control-label ">
Project Name
</label>
<div class="input-group">
<input class="form-control" type="text" [value]="project.name" />
</div>
</div>
<div class="form-group">
<label class="control-label ">
Project Number
</label>
<div class="input-group">
<input class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<label class="control-label ">
Project Creator
</label>
</div>
</div>
<div class="col-lg-3">
<div class="form-group">
<label class="control-label ">
Team
</label>
<div class="input-group">
<input class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<label class="control-label ">
Team ID
</label>
<div class="input-group">
<input class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<label class="control-label ">
Team Manager
</label>
</div>
</div>
<div class="col-lg-3">
<div>
<div class="card" style="width: 100%;">
<div class="container">
<h4><b>Project Details</b></h4>
<p >One team of students collected data from a consumer Internet website with automobile specificatins.The summary slide shows the results of their linear regression analysis on car engine horsepower and average miles per gallon (MPG) ratings</p>
</div>
</div>
</div>
</div>
</div>
css
.card {
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.3s;
}
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
}
.container {
padding: 2px 16px;
}
Bootstrap container is conflicting with with "tutorial" container.
Use a special container class for the card...
<div class="col-lg-3">
<div>
<div class="card" style="width: 100%;">
<div class="card-container">
..
</div>
</div>
</div>
</div>
.card-container {
padding: 2px 16px;
}

Removing white space on the right side of a page

I am aware this is very basic but I have been trying so many ways of removing the white space on the right side of my page yet still it's been a little problem for me as a learner. The sign_in and paratext are inline as shown but when I used set the margins and paddings to 0 to remove the white space from the right side of my page, the sign in (which is the login form) moves below the paratext instead of staying inline.
Here you go. Hope this helps you.
body {
margin: 0;
padding: 0;
}
.sign_in {
display: inline-block;
width: 55%;
font-size: 3vw;
margin-left: 30px;
}
.paratext {
display: inline-block;
font-size: 3vw;
width: 35%;
color: #008B8B;
}
<html>
<head>
<title>Example</title>
</head>
<body>
<div class="paratext">
<h1>Get ready to sell Smarter, Better, Faster.</h1>
<p>Dosty CRM is the latest e-customer relationship management system being used currently by tech companies. Easy and Secure. </p>
</div>
<div class="sign_in" id="sign_in">
<form (ngSubmit)="submitForm(l)" #l="ngForm">
<h1 style="color:#008B8B; font-weight: 900; font-size: 40px;" > <b>Sign In </b></h1><br>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="email">Email</label>
<input type="text" class="form-control" id="email" name="email" placeholder="First Name" [(ngModel)]="login.email" required>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="password" [(ngModel)]="login.password">
</div>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<div class="form-group">
<input type="checkbox" value="Remember Me" id="remember_me" >
<label >Remember Me </label>
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<p class="text-right"><span class="forgot-password"><a style=" color:#008B8B;" href="#">Forgot password?</a></span></p>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-2">
<div class="form-group">
<button class="button" type="submit" style="font-weight: 900; background-color:#008B8B;" ><span>Login </span></button>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<p class="text-right">
<span><a style="color:#008B8B;" href="#">Already a member?</a></span></p>
</div>
</div>
</div>
</form>
</div>
</body>
<html>
I have refactored your code by removing irrelevant row classes and inline styles. You also specified sign_in{width:70%}, but haven't specified what is 100%, so I added body{width:100%}. In addition to that, I commented out certain paddings and margins you can see that in the example below.
body{width: 100%;}
.paratext, h1, a{color:#008B8B;}
h1{
font-weight: 900;
font-size: 40px;
}
.form-group button{
font-weight: 900;
background-color:#008B8B;
}
.sign_in {
width: 70%;
/*margin-right: -30%;*/
}
.paratext {
display: inline-block;
/*padding-top: 250px;*/
font-size: 16px;
word-wrap: break-word;
/*width: 600px;*/
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<body>
<div class="paratext">
<h1>Get ready to sell Smarter, Better, Faster.</h1>
<p>Dosty CRM is the latest e-customer relationship management system being used currently by tech companies. Easy and Secure.</p>
</div>
<div class="sign_in" id="sign_in">
<form (ngSubmit)="submitForm(l)" #l="ngForm">
<h1>Sign In</h1>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<label for="email">Email</label>
<input type="text" class="form-control" id="email" name="email" placeholder="First Name" [(ngModel)]="login.email" required>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="password" [(ngModel)]="login.password">
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<input type="checkbox" value="Remember Me" id="remember_me">
<label>Remember Me</label>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<p class="text-right forgot-password">Forgot password?</p>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<button class="button" type="submit">Login</button>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<p class="text-right">Already a member?</p>
</div>
</div>
</div>
</form>
</div>
</body>
Try this code example in your project and see if the problem remains. If you still have a problem then you need to update you question with the rest of the codebase you have.

Bootstrap HTML form, not responsive

I have created an html form using bootstrap columns to get the desired layout. It's about where I want it for desktop but it piles together on mobile. I don't believe any of the code I've used is working with bootstrap. Here is the form itself:
<div class="center_div">
<div class="row">
<div class="form-group col-xs-5">
<h3>First Name</h3>
<input name="fName" type="text" />
</div>
<div class="form-group col-xs-5">
<h3>Last Name</h3>
<input name="lName" type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-xs-5">
<h3>Company Name</h3>
<input name="compName" type="text" />
</div>
<div class="form-group col-xs-5">
<h3>Business Type</h3>
<select class="form-control" style="width: 100%;" name="businessNeeds">
<option value="">Select...</option>
<option value="IntDesign">Interior Designer</option>
<option value="Ecom">E-Commerce Only</option>
<option value="Retail">Retail Store Only</option>
<option value="RetailEcom">Retail and E-Commerce</option>
<option value="Mult">Multiple Locations</option>
</select>
</div>
</div>
<div class="row">
<div class="col-xs-10">
<div class="input-group input-group-xs">
<h3>Address</h3>
<input class="form-control input-lg" name="address" type="text" />
</div>
</div>
</div>
<div class="row">
<div class="form-group col-xs-5">
<h3>City</h3>
<input name="city" type="text" />
</div>
<div class="form-group col-xs-2">
<h3>State</h3>
<select name="state">
<option value="">Select...</option>
/*Took out states for space*/
</select>
</div>
<div class="form-group col-xs-3">
<h3>Zip</h3>
<input name="zip" type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-xs-5">
<h3>Phone</h3>
<input name="phone" type="text" />
</div>
<div class="form-group col-xs-5">
<h3>Email</h3>
<input id="email" name="uemail" type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-xs-4">
<h3>Create a Username</h3>
<input name="uname" type="text" />
</div>
<div class="form-group col-xs-3">
<h3>Create a Password</h3>
<input class="form-control" style="width: 100%;" name="pass" type="password" />
</div>
<div class="form-group col-xs-3">
<h3>Confirm Password</h3>
<input class="form-control" style="width: 100%;" name="ConfPass" type="password" />
</div>
</div>
<div class="row">
<div class="form-group col-xs-5">
<h3>Sales Tax ID</h3>
<input name="taxID" type="text" />
</div>
<div class="form-group col-xs-5">
<h3>Upload Tax ID Certificate</h3>
<input name="fileUpload" type="file" />
</div>
</div>
<div class="buttonHolder">
<input type="submit" value="Submit" /></div>
</div>
</form>
The CSS:
.center_div{
padding-left:150px;
position:relative;
width:100%;
margin:0 auto;
}
#media only screen and (max-width: 600px){
.mainForm{
}
.center_div{
width:100%;
margin:0 0 15px 0;
}
.center_div label{
width:100%;
float: none;
margin:0 0 5px 0;
}
.mainForm is a blank div around the form, there is nothing else on the page. I left the CSS pretty barebones but is there a fairly simple way to make this respond better on mobile with bootstrap? Even if all the fields just sat on top of one another.
All your bootstrap rows must be inside a .container div, otherwise they will not work as expected.
In order to stack form elements on smaller screens and have (say) two columns (6 grid columns each, really) on bigger resolutions, you need to apply two classes to your cols.
<div class="form-group col-xs-12 col-sm-6">
Essentially you're telling bootstrap that from the smallest resolution (xs) on the element should span 12 grid columns, while for small resolutions (sm) on the element should span 6 grid columns.
On this codepen I added these classes so you can see the solution at work. Hope it helps.
<html>
<head>
<title>
Mobile form responsvie
</title>
<style>
<style>
.row
{
display: flex;
flex-direction: column;
}
.form-group.col-xs-5 {
margin-left: 30px;
}
.input-inline
{
width:50%;
}
.input-inline
{
width:50%;
}
.center_div {
padding-left: 50px;
padding-right: 50px;
}
#media only screen and (max-width: 720px)
{
.input-inline
{
}
h3{
color:grey;
}
.form-group.col-xs-5
{
margin-left: 0px;
}
.center_div label{
width:100%;
float: none;
margin:0 0 5px 0;
}
.buttonolder input {
margin-left: 18%;
cursor: pointer;
}
</style>
</style>
</head>
<body>
<form>
<div class="center_div">
<div class="row">
<div class="form-group col-xs-5">
<h3>First Name</h3>
<input class="input-inline" name="fName" type="text" />
</div>
<div class="form-group col-xs-5">
<h3>Last Name</h3>
<input class="input-inline" name="lName" type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-xs-5">
<h3>Company Name</h3>
<input class="input-inline" name="compName" type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-xs-5">
<h3>Business Type</h3>
<select name="businessNeeds">
<option value="">Select...</option>
<option value="IntDesign">Interior Designer</option>
<option value="Ecom">E-Commerce Only</option>
<option value="Retail">Retail Store Only</option>
<option value="RetailEcom">Retail and E-Commerce</option>
<option value="Mult">Multiple Locations</option>
</select>
</div>
</div>
<div class="row">
<div class="form-group col-xs-5">
<h3>Address</h3>
<input class="input-inline" class="form-control input-lg" name="address" type="text"/>
</div>
</div>
<div class="row">
<div class="form-group col-xs-5">
<h3>City</h3>
<input class="input-inline" name="city" type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-xs-5">
<h3>State</h3>
<select name="state">
<option value="">Select...</option>
/*Took out states for space*/
</select>
</div>
</div>
<div class="row">
<div class="form-group col-xs-5">
<h3>Zip</h3>
<input class="input-inline" name="zip" type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-xs-5">
<h3>Phone</h3>
<input class="input-inline" name="phone" type="text" />
</div>
<div class="form-group col-xs-5">
<h3>Email</h3>
<input class="input-inline" id="email" name="uemail" type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-xs-5">
<h3>Create a Username</h3>
<input class="input-inline" name="uname" type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-xs-5">
<h3>Create a Password</h3>
<input class="input-inline" class="form-control" name="pass" type="password" />
</div>
<div class="form-group col-xs-5">
<h3>Confirm Password</h3>
<input class="input-inline" class="form-control"name="ConfPass" type="password" />
</div>
</div>
<div class="row">
<div class="form-group col-xs-5">
<h3>Sales Tax ID</h3>
<input class="input-inline" name="taxID" type="text" />
</div>
</div>
<div class="row">
<div class="form-group col-xs-5">
<h3>Upload Tax ID Certificate</h3>
<input class="upload-file" name="fileUpload" type="file" />
</div>
</div>
<div class="row">
<div class="buttonolder">
<input class="upload-file" type="submit" value="Submit" style="margin-left: 21%;margin-top: 3%;text-align: center;padding: 8px;padding-left: 27px;padding-right: 27px;cursor: pointer;">
</div>
</div>
</div>
</form>
</body>
</html>

How to place Bootstrap form inputs closer to eachother?

I'm building a form using Bootstrap in which I need to place many inputs on one line like if it where a Spreadsheet. So using the regular Bootstrap grid system I did this (snippet):
<div class="col-sm-1">
<div class="form-group">
<textarea placeholder="Description" class="form-control" rows="1" required></textarea>
</div>
</div>
<div class="col-sm-1">
<input placeholder="Remaining contract term" class="form-control" type="text">
</div>
<div class="col-sm-1">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">€</div>
<input placeholder="Contract rental" class="form-control" type="text">
</div>
</div>
</div>
etc.
which results in:
Obviously that looks horrible. For this specific form I need to place the inputs closer to eachother so that they (almost) touch eachother.
Does anybody know how I can style this better? All tips are welcome!
You could override the padding on the col-sm-* with a class like this
.inputItem {
padding-left: 2px;
padding-right: 2px;
}
This might be useful.
You can adjust your column padding by media queries in the event you want the form to stack on smaller devices so the padding returns to normal.
#media (min-width: 768px) {
form .form-gutter >[class*='col-'] {
padding-right: 1px;
padding-left: 1px;
}
}
form .form-control,
form .input-group-addon {
border-radius: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<form class="form">
<div class="container-fluid">
<h1>Form </h1>
<div class="row form-gutter">
<div class="col-sm-2">
<div class="form-group">
<div class="input-group">
<input placeholder="Contract rental" class="form-control" type="text">
<div class="input-group-addon">€</div>
</div>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">Some</label>
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">Thing</label>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<input placeholder="Remaining contract term" class="form-control" type="text">
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<input placeholder="Remaining contract term" class="form-control" type="text">
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">€</div>
<input placeholder="Contract rental" class="form-control" type="text">
</div>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">€</div>
<input placeholder="Contract rental" class="form-control" type="text">
</div>
</div>
</div>
</div>
</div>
</form>