Formatting columns with Bootstrap - css

I have a container containing a single row with two columns and am trying to format the left column so that it looks similar to a sidebar: full height and extending all the way to the left.
I used flex classes for this but ran into a couple problems:
the columns doesn't extend all the way down
the text "spreads" out instead of staying aligned in the center like before
Code without full height column:
<div class="container">
<form enctype=multipart/form-data action={{url_for('upload_file')}} method="POST" enctype="multipart/form-data"></form>
<div class="row">
<div class="col-sm-4 bg-light">
<br>
<br>
<h4>Select a model:</h4>
<input type="radio" id="logreg" name="model" value="logreg" required>
<label for="male">Logistic regression</label><br>
<input type="radio" id="knn" name="model" value="knn">
<label for="male">K-nearest neighbors</label><br>
<input type="radio" id="randomforest" name="model" value="randomforest">
<label for="male">Random forest</label><br>
<input type="radio" id="svm" name="model" value="svm">
<label for="male">Kernel SVM</label><br>
<br>
<h4>Visuals</h4>
<input type="checkbox" id="mel" name="mel" value="mel">
<label for="mel"> Show Mel-Spectrogram</label><br>
<input type="checkbox" id="chroma" name="chroma" value="chroma">
<label for="chroma"> Show Chroma Spectrogram</label><br>
<input type="checkbox" id="tempo" name="tempo" value="tempo">
<label for="tempo"> Show Tempogram</label><br>
<br>
<p>See the project on GitLab</p>
</div>
<div class="col-sm-8">
<br>
<br>
<h3>Music Genre Recognition</h3>
<p>We created an algorithm that can recognize the musical genre of an audio file.<br>
To try it, upload a file and choose a model, then click submit.</p>
<p>It can take up to a few minutes so be patient !</p>
<h3>Choose a file:</h3>
<br>
<input type="file" name="file" accept=".wav, .mp3" class="form-control" id="customFile" required/><br>
<button type="submit" class="btn btn-outline-secondary">Submit</button>
</div>
</div>
</form>
</div>
And this is the result:
This is the html where I tried to make the left column full height:
<div class="container-fluid d-flex h-100">
<form enctype=multipart/form-data action={{url_for('upload_file')}} method="POST" enctype="multipart/form-data"></form>
<div class="row flex-fill">
<div class="col-sm-4 bg-light d-flex flex-column flex-fill">
<br>
<br>
<h4>Select a model:</h4>
<input type="radio" id="logreg" name="model" value="logreg" required>
<label for="male">Logistic regression</label><br>
<input type="radio" id="knn" name="model" value="knn">
<label for="male">K-nearest neighbors</label><br>
<input type="radio" id="randomforest" name="model" value="randomforest">
<label for="male">Random forest</label><br>
<input type="radio" id="svm" name="model" value="svm">
<label for="male">Kernel SVM</label><br>
<br>
<br>
<h4>Visuals</h4>
<input type="checkbox" id="mel" name="mel" value="mel">
<label for="mel"> Show Mel-Spectrogram</label><br>
<input type="checkbox" id="chroma" name="chroma" value="chroma">
<label for="chroma"> Show Chroma Spectrogram</label><br>
<input type="checkbox" id="tempo" name="tempo" value="tempo">
<label for="tempo"> Show Tempogram</label><br>
<br>
<br>
<br>
<p>See the project on GitLab</p>
</div>
<div class="col-sm-8">
<br>
<br>
<h3>Music Genre Recognition</h3>
<p>We created an algorithm that can recognize the musical genre of an audio file.<br>
To try it, upload a file and choose a model, then click submit.</p>
<p>It can take up to a few minutes so be patient !</p>
<h3>Choose a file:</h3>
<br>
<input type="file" name="file" accept=".wav, .mp3" class="form-control" id="customFile" required/><br>
<button type="submit" class="btn btn-outline-secondary">Submit</button>
</div>
</div>
</form>
</div>
And this is the result:
How can I make this column full height and keep the text like in the first example ?

Bootstrap has some height utility classes that can stretch the height to be the same as the view port (.min-vh-100). If you apply this to the div with the .row class, flex should take care of stretching the columns to fill the space.
<div class="row min-vh-100">
...
</div>

Related

Bootstrap 3 - Space between inputs with Icons and custom width

I'm facing a problem I don't really know how to deal with.
I'm working on BootStrap 3 and i'm trying to make some inline forms because it is more user-friendly than a full vertical form (I don't want to scroll for ever)
I find some way to inline the normal inputs, but when it comes to the input with icons (font awesome), I can figure how to inline them, but they inline side to side without any space between them.
Also, I don't figure out how to change their width as I would do with normal input (col-sm-4 for example).
I would like the "Email" and "Telephone" to be scaped and to change their width
Please have a look at my code and the following image explaining it:
http://www.bootply.com/T8w3oRE3Sn
You were missing few things in the form group so I have wrapped things up. Hope it will help you :)
Below is the working snippet:
.myform .form-inline .input-group .input-group-addon{ width:20px;}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="row myform">
<div class="col-xs-12">
<form name="myform" role="form" novalidate>
<div class="form-inline ">
<div class="form-group col-xs-6">
<div class="input-group col-xs-12">
<span class="input-group-addon"><i class="fa fa-envelope"></i></span>
<input type="email" class="form-control" placeholder="Email de l'interlocuteur">
</div>
</div>
<div class="form-group col-xs-6">
<div class="input-group col-xs-12">
<span class="input-group-addon"><i class="fa fa-phone"></i></span>
<input type="email" class="form-control" placeholder="Téléphone de l'interlocuteur">
</div>
</div>
</div>
</form>
</div>
</div>
Try this
IF you see it in large screen it will be inline.
You have to use form-inline class to make form inline.
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container">
<form class="form-inline">
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" placeholder="Enter email">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd" placeholder="Enter password">
</div>
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
You just need to deal with good understanding of bootstrap grid system
<div class="form-group row">
<label for="inputEmail3" class="col-sm-1 control-label">Interlocuteur</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="inputEmail3">
</div>
<label for="inputEmail5" class="col-sm-1 control-label">Poste</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="inputEmail5" placeholder="DeInterlocuteur">
</div>

Evenly separate radio buttons using bootstrap

My radio buttons are too close together and I would like them to evenly be displayed across the row using the bootstrap grid system. Any idea's on how I can accomplish this?
<div class="radio">
<div class="row">
<div class="col-md-12">
<label>
<input id="visitors_radio" name="user[role]" type="radio">
Visitors
</label>
<label>
<input id="staff_radio" name="user[role]" type="radio">
Staff
</label>
<label>
<input id="volunteer_radio" name="user[role]" type="radio">
Volunteer
</label>
</div>
</div>
</div>
<div class="radio">
<div class="row">
<div class="col-md-4">
<label>
<input id="visitors_radio" name="user[role]" type="radio">
Visitors
</label>
</div>
<div class="col-md-4">
<label>
<input id="staff_radio" name="user[role]" type="radio">
Staff
</label>
</div>
<div class="col-md-4">
<label>
<input id="volunteer_radio" name="user[role]" type="radio">
Volunteer
</label>
</div>
</div>
</div>
Make use of the bootstrap grid to help you to achieve that.

How to set form fields size with bootstrap?

I am trying to create a form with bootstrap. Here is my source code:
<div class="container">
<form action="" method="post" id="payment-form" novalidate autocomplete="on">
<span class="payment-errors"></span>
<div class="form-group">
<label for="cc-number" class="control-label">Card number formatting <small class="text-muted">[<span class="cc-brand"></span>]</small></label>
<input id="cc-number" type="tel" class="input-lg form-control cc-number" autocomplete="cc-number" placeholder="•••• •••• •••• ••••" required class="col-md-2">
</div>
<div class="form-group">
<label for="cc-exp" class="control-label">Card expiry formatting</label>
<input id="cc-exp" type="tel" class="input-lg form-control cc-exp" autocomplete="cc-exp" placeholder="•• / ••" required class="col-md-2">
</div>
<div class="form-group">
<label for="cc-cvc" class="control-label">Card CVC formatting</label>
<input id="cc-cvc" type="tel" class="input-lg form-control cc-cvc" autocomplete="off" placeholder="•••" required class="col-md-2">
</div>
<button type="submit" class="btn btn-lg btn-primary">Submit</button>
<h2 class="validation"></h2>
</form>
</div>
I want to do size="30" for fields. But the fields are still too large and this size doesn't affect fields. What changes should I do?
Please use this class
col-md-3 or col-md-2. Please use width="30px", hope this will help you.
EDITED:
if div is your main tag then put the code like
<div class="form-group">
<label for="cc-number" class="control-label">Card number formatting <small class="text-muted">[<span class="cc-brand"></span>]</small></label>
<input id="cc-number" type="tel" class="input-lg form-control cc-number" autocomplete="cc-number" placeholder="•••• •••• •••• ••••" class="col-md-3">
</div>
or you can use width like
<div class="form-group">
<label for="cc-number" class="control-label">Card number formatting <small class="text-muted">[<span class="cc-brand"></span>]</small></label>
<input id="cc-number" type="tel" class="input-lg form-control cc-number" autocomplete="cc-number" placeholder="•••• •••• •••• ••••" style="width:30px !important">
</div>
Meaning of numbers in col-md-4 , col-xs-1 , col-lg-2 in bootstrap
please let me know if you have any confusion.\
Thank you

Bootstrap append a textfield inline with a radio btn

I am looking for a way to append a text field inline with a radio button, I am currently using Boostrap. If someone know a specific class for this purpose, that will be appreciated.
My current approach is always mis-aligned, the textbox goes right under the radio button which is something i dont want.
JSFiddle here. http://jsfiddle.net/fs85eedu/
<div class="radio">
<label class="control-label">
<input type="radio" name="radioname" id="radioid" class="radio_class">
<label>text here</label>
<div class='row'>
<div class="col-md-5">
<input type="text" id="q4_c_1_2" name="q4_c_text" placeholder="Enter role/titile" class="form-control">
</div>
</div>
</label>
</div>
Maybe something like this. Just put both controls in same row.
<div class="radio">
<div class='row'>
<div class="col-md-2">
<label class="control-label"></label>
<input type="radio" name="radioname" id="radioid" class="radio_class">
<label>text here</label>
</div>
<div class="col-md-3">
<input type="text" id="q4_c_1_2" name="q4_c_text" placeholder="Enter role/titile" class="form-control">
</div>
</div>
</div>

Bootstrap 3 inline-form with different widths for input boxes

I have some bootstrap 3.0 based markup that produces an inline form like this:
The code for this is:
<div class="container">
<form class="form-inline" role="form" id="gh_save">
<div class="form-group">
<input type="text" placeholder="Github username" class="form-control" id="gh_user">
</div>
<div class="form-group">
<div class="col-lg-6">
<input type="text" placeholder="API Key" class="form-control" id="gh_apikey">
</div>
</div>
<button type="submit" class="btn btn-success"> Save </button>
</form>
I am trying to increase the width of the second box (API Key) to be twice what it is now, but no matter what I change the width of the div holding the second input is changing the width. Can someone show me how this done?
when I manually set the width of the second INPUT, I get this:
<form class="form-horizontal">
<div class="form-group">
<div class="col-xs-4">
<input type="text" placeholder="Github username" class="form-control" id="gh_user"/>
</div>
<div class="col-xs-6">
<input type="text" placeholder="API Key" class="form-control" id="gh_apikey" />
</div>
<div class="col-xs-2">
<button type="submit" class="btn btn-success"> Save </button>
</div>
</div>
</form>
DEMO
PS : close input tags as <input class="" />
Final edit here, I guess external bootstrap 3.1.1 was not getting included thus you got the result in 3 different lines, take a look at this
Final Demo
<link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<div class="container">
<form class="form-inline" role="form" id="gh_save">
<div class="form-group">
<div class="col-xs-4">
<input type="text" placeholder="Github username" class="form-control" id="gh_user"/>
</div>
</div>
<div class="form-group">
<div class="col-xs-6">
<input type="text" placeholder="API Key" class="form-control" id="gh_apikey"/>
</div>
</div>
<div class="form-group">
<div class="col-xs-2">
<button type="submit" class="btn btn-success"> Save </button>
</div>
</div>
</form>
</div>
You should be able to target your ID within your css and set your desired width like so:
#gh_apikey{width:400px;}

Resources