Multiple input box in inline form - html

I use the solution provide by #dippas here
Inline form make input text full width and responsive
My new request is how to put multiple input text and fill all the space.
I am aware that we can not use width with inline form like mention in bootstrap website
Requires custom widths Inputs, selects, and textareas are 100% wide by
default in Bootstrap. To use the inline form, you'll have to set a
width on the form controls used within. The default width of 100% as
all form elements gets when they got the class form-control didn't
apply if you use the form-inline class on your form.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<style>
.form-inline {
display: flex;
padding:5px !important;
}
.flex {
flex: 1;
display: flex !important
}
.flex input {
flex: 1 !important ;
padding-right:15px !important;
}
.form-inline .form-group {
padding-right:15px !important;
}
</style>
<div class="panel panel-primary">
<div class="panel-heading">
<h4><b>Search Options</b></h4>
</div>
<div class="panel-body">
<form class="form-inline">
<div class="form-group">
<div class="btn-group">
<button type="button"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
>Account ID <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Account ID</li>
<li>Company Name</li>
<li>Account Type</li>
<li>Marketplaces</li>
</ul>
</div>
</div>
<div class="row" style="display: block">
<div class="form-group flex" >
<input class="form-control" type="text" value="" id="filter_id" placeholder="Put your filter here">
<button type="button" class="btn btn-danger"> Fermer </button>
</div>
<div class="form-group flex">
<input class="form-control" type="text" value="" id="filter_id" placeholder="Put your filter here">
<button type="button" class="btn btn-danger"> Fermer </button>
</div>
<div class="form-group flex">
<input class="form-control" type="text" value="" id="filter_id" placeholder="Put your filter here">
<button type="button" class="btn btn-danger"> Fermer </button>
</div>
</div>
</form>
</div>
</div>

you need to add display:flex to .row, because now the parent of .flex is .row
/* !important only for this snippet */
.form-inline {
display: flex;
padding: 5px !important;
}
.row {
display: flex;
flex-wrap: wrap;
flex: 1
}
.flex {
flex: 0 100%;
display: flex !important
}
.flex input {
flex: 1 !important;
padding-right: 15px !important;
}
.form-inline .form-group {
padding-right: 15px !important;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="panel panel-primary">
<div class="panel-heading">
<h4><b>Search Options</b></h4>
</div>
<div class="panel-body">
<form class="form-inline">
<div class="form-group">
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Account ID <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Account ID</li>
<li>Company Name</li>
<li>Account Type</li>
<li>Marketplaces</li>
</ul>
</div>
</div>
<div class="row">
<div class="form-group flex">
<input class="form-control" type="text" value="" id="filter_id" placeholder="Put your filter here">
<button type="button" class="btn btn-danger"> Fermer </button>
</div>
<div class="form-group flex">
<input class="form-control" type="text" value="" id="filter_id" placeholder="Put your filter here">
<button type="button" class="btn btn-danger"> Fermer </button>
</div>
<div class="form-group flex">
<input class="form-control" type="text" value="" id="filter_id" placeholder="Put your filter here">
<button type="button" class="btn btn-danger"> Fermer </button>
</div>
</div>
</form>
</div>
</div>

Related

how to align divs inside a td horizontally?

as shown in the image,things are deranged a bit, maybe its because its inside a td.
is it possible to do that?
<td>
<div class="col">
<div class="input-group text-center">
<div class="input-group-btn">
<button class="btn btn-primary" type="submit" id="button-minus"> - </button>
</div>
<input type="text" class="form-control" value="1" size="1">
<div class="input-group-btn">
<button class="btn btn-primary" type="submit" id="button-plus"> + </button>
</div>
</div> <!-- input-group.// -->
</div> <!-- Col.// -->
</td>
You might try to remove the default Bootstrap padding and margin for td, p, button and try :
td {
padding: 0;
margin: 0;
}
You can place the buttons and form on the same line by adding display: inline-flex to .input-group
.input-group {display: inline-flex}
<td>
<div class="col">
<div class="input-group text-center">
<div class="input-group-btn">
<button class="btn btn-primary" type="submit" id="button-minus"> - </button>
</div>
<input type="text" class="form-control" value="1" size="1">
<div class="input-group-btn">
<button class="btn btn-primary" type="submit" id="button-plus"> + </button>
</div>
</div> <!-- input-group.// -->
</div> <!-- Col.// -->
</td>

How to place two input next to each other in bootstrap 4

I want to place the text input and the button next to each other, with about 10px margin between them.
Whit this code, i get the result what you can see on the uploaded photo.
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="float-left">
<input type="number" class="form-control item_page_item_db w-50" id="quantity<?php echo intval($kat['termek_id']); ?>" value="1">
</div>
<div class="float-left">
<button class="btn btn-outline-secondary add_to_cart_button" data-product-id="<?php echo intval($kat['termek_id']); ?>" type="button"><i class="fa fa-shopping-basket" aria-hidden="true"></i> Kosárba helyezem
</button>
</div>
<div class="clearfix"></div>
</div>
I want them closer to each other, and vertically centered the right way. Now, they dont have any css for size, only just colors and font size...
The bootstrap way: Use col classes to create a width (Shown below)
.row {
background: #f8f9fa;
margin-top: 20px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-sm-2">
<input type="number" class="form-control" value="1">
</div>
<div class="col-sm-10">
<button class="btn btn-outline-secondary" type="button">
<i class="fa fa-shopping-basket"></i>
Kosárba helyezem
</button>
</div>
</div>
</div>
Pure CSS way:
.cont {
display: flex;
}
input {
width: 100px !important; /**use specific width**/
margin-right: 10px !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="cont">
<input type="number" class="form-control" value="1">
<button class="btn btn-outline-secondary" type="button">
<i class="fa fa-shopping-basket"></i>
Kosárba helyezem
</button>
</div>
See the below structure and css. Hope it helps.
.col-sm-6 input[type="number"]{width:100%}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-sm-6">
<input type="number" class="form-control item_page_item_db" id="quantity<?php echo intval($kat['termek_id']); ?>" value="1">
</div>
<div class="col-sm-6">
<button class="btn btn-outline-secondary add_to_cart_button" data-product-id="<?php echo intval($kat['termek_id']); ?>" type="button"><i class="fa fa-shopping-basket" aria-hidden="true"></i> Kosárba helyezem
</button>
</div>
<div class="clearfix"></div>
</div>
</div>
You can use col-md-6 class instead of float-left or right.

How can I vertically center a span that takes up 2 rows with an adjacent column that only takes up 1 row?

Here is a picture of my issue. I want the Live span to be centered with the 2 date pickers.
Here is the JSFiddle.
And the code:
<div class="row">
<div class="col-xs-6"><span>Live</span></div>
<div class="col-xs-6">
<div class="row">
<div class="col-xs-12">
<p class="input-group">
<input type="text" max-date="'2016-9-26'" class="form-control" uib-datepicker-popup="{{format}}" ng-model="start_dt" is-open="open['start_dt']" datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="altInputFormats">
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="open('start_dt')"><i class="glyphicon glyphicon-calendar"></i></button>
</span>
</p>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<p class="input-group">
<input type="text" max-date="'2016-9-26'" class="form-control" uib-datepicker-popup="{{format}}" ng-model="end_dt" is-open="open['end_dt']" datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="altInputFormats">
<span class="input-group-btn">
<button type="button" class="btn btn-gray btn-default" ng-click="open('end_dt')"><i class="glyphicon glyphicon-calendar"></i></button>
</span>
</p>
</div>
</div>
</div>
</div>
You can do this with flexbox. Assign display: flex; and align-items: center; to your .row.
CSS
.row {
display: flex;
align-items: center;
}
JSFiddle
Note* You might want to give that .row div a unique class and assign the properties to it.
Flexbox is a what I would have suggested but browser support isn't that great for it. You could just add some padding to the span
span.add-padding {
padding: 24px 0;
display:inline-block;
}
<span class="add-padding">Live</span>
https://jsfiddle.net/mikeilk/0dsbvhhu/

Bootstrap 3: Horizontal form group inside dropdown

The requirement is a horizontal form group inside of a dropdown. When the user clicks the dropdown, they are able to enter text into the appearing text fields.
I am losing control over the width and margin of the form group when inside of the dropdown. For example, the following form group renders fine:
<form class="form-horizontal">
<div class="form-group">
<label for="strike-from" class="col-sm-2 control-label">From</label>
<div class="col-xs-1">
<input type="text" class="form-control" id="strike-from" value="">
</div>
</div>
<div class="form-group">
<label for="strike-to" class="col-sm-2 control-label">To</label>
<div class="col-xs-1">
<input type="text" class="form-control" id="strike-to" value=""">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Apply</button>
</div>
</div>
</form>
However when embedding this same HTML inside of a dropdown wrapper, the text fields extend past the container and the margin is compressed.
<div class="form-inline">
<div class="form-group">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="strikes-range" data-toggle="dropdown" aria-haspopup="true">
Strikes
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="strikes">
<li>
<form class="form-horizontal">
<div class="form-group">
<label for="strike-from" class="col-sm-2 control-label">From</label>
<div class="col-xs-1">
<input type="text" class="form-control" id="strike-from" value="">
</div>
</div>
<div class="form-group">
<label for="strike-to" class="col-sm-2 control-label">To</label>
<div class="col-xs-1">
<input type="text" class="form-control" id="strike-to" value="">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Apply</button>
</div>
</div>
</form>
</li>
</ul>
</div>
</div>
</div>
Is there an out of the box implementation of this? Otherwise do I just need to add custom styles for width of text boxes and margin?
Or am I just implementing something incorrectly?
I have edited some column widths and removed an extra " and added a class donotchange for removing the alignment error.
Here is my code
HTML
<div class="form-inline">
<div class="form-group">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="strikes-range" data-toggle="dropdown" aria-haspopup="true"> Strikes <span class="caret"></span> </button>
<ul class="dropdown-menu" aria-labelledby="strikes">
<li style="width: 280px;">
<form class="form-horizontal" style="display:block;">
<div class="form-group donotchange">
<label for="strike-from" class="col-sm-2 control-label">From</label>
<div class="col-xs-8">
<input type="text" class="form-control" id="strike-from" value="">
</div>
</div>
<div class="form-group donotchange">
<label for="strike-to" class="col-sm-2 control-label">To</label>
<div class="col-xs-8">
<input type="text" class="form-control" id="strike-to" value="">
</div>
</div>
<div class="form-group donotchange">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Apply</button>
</div>
</div>
</form>
</li>
</ul>
</div>
</div>
<!-- No need. For checking Only-->
<div class="form-group">
<button class="btn btn-default dropdown-toggle" type="button" id="strikes-range" data-toggle="dropdown" aria-haspopup="true"> Sample Button </button>
</div>
<div class="form-group">
<input type="text" class="form-control" id="strike-to" value="">
</div>
<!-- No need. For checking Only-->
</div>
CSS
#media (min-width: 768px){
.form-inline .donotchange {
display: block;
margin-bottom: 10px;
vertical-align: middle;
}
.form-horizontal .donotchange {
margin-right: 0px;
margin-left: 0px;
}}
#media (min-width: 768px){
.form-inline .donotchange {
display: block;
margin-bottom: 10px;
vertical-align: middle;
}}
Check my working code here http://www.bootply.com/N0lccYSCsg
Check whether it works as per your requirements.
Good day!

Taking up Horizontal Space and Vertical space in Bootstrap Column

I have this setup here:
As you can see the Left Option Button is big and that's how I need all the buttons to be. They need to be lined up next to each other as I use the Bootstrap grid system with 3x4 columns. The button is currently the size it is (and doesn't take up all available horizontal space) because I applied this line to my HTML:
style="width: 400%; height: 500%;"
It was simply to provide a visual aid for what I'm aiming to do. I'm fairly new with bootstrap so learning how to style it is a bit tricky for me. Below is my html. Do I need CSS to achieve what I want above? If so, do I need to hardcode how "tall" I want the buttons to be or can I use some sort of relative method to do so, so that I won't run into problems if the site is viewed on a mobile phone?
I also need to place a text in the button that scales up properly but I'm sure that's doable once the buttons are scaled correctly?
<div class="categories-container">
<div class="container">
<div class="row">
<div class="col-md-4">
<form role="button">
<div class="input-group">
<input type="button" class="btn btn-primary btn-lg" value="Option" name="category-gameplay-btn" id="category-gameplay-btn">
</div>
</form>
</div>
<div class="col-md-4">
<form role="button">
<div class="input-group">
<input type="button" class="btn btn-primary btn-lg" value="Option" name="category-editor-btn" id="category-editor-btn">
</div>
</form>
</div>
<div class="col-md-4">
<form role="button">
<div class="input-group">
<input type="button" class="btn btn-primary btn-lg" value="Option" name="category-editor-btn" id="category-editor-btn">
</div>
</form>
</div>
</div>
</div>
</div>
Here are two example of what I think you're trying to do.
1) Uses a Justified button group instead of the grid and uses media queries to adjust to the viewport size.
2) Uses the grid like in your example and then just uses media queries to adjust to the viewport size.
See example Snippet.
.btn.btn-bg {
height: 300px;
font-size: 60px;
}
#media (max-width: 767px) {
.btn.btn-bg {
height: 150px;
font-size: 30px;
}
}
#media (max-width: 480px) {
.btn.btn-bg {
height: 75px;
font-size: 22px;
}
}
#media (max-width: 360px) {
.btn.btn-bg {
height: 35px;
font-size: 15px;
}
}
/*Second Sample*/
.btn.btn-bg2 {
height: 300px;
font-size: 60px;
}
#media (max-width: 767px) {
.btn.btn-bg2 {
height: 60px;
font-size: 30px;
}
}
#media (max-width: 480px) {
.btn.btn-bg2 {
height: 45px;
font-size: 20px;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="well">
<form role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span>
</button>
</div>
</div>
</form>
</div>
</div>
<div class="categories-container">
<div class="container">
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-bg">Left</button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-bg">Middle</button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-bg">Right</button>
</div>
</div>
</div>
</div>
<hr>
<div class="container">
<div class="well">
<form role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span>
</button>
</div>
</div>
</form>
</div>
</div>
<div class="categories-container">
<div class="container">
<div class="row ">
<div class="col-sm-4">
<input type="button" class="btn btn-primary btn-lg btn-block btn-bg2" value="Option" name="category-gameplay-btn" id="category-gameplay-btn">
</div>
<div class="col-sm-4">
<input type="button" class="btn btn-primary btn-lg btn-block btn-bg2" value="Option" name="category-editor-btn" id="category-editor-btn">
</div>
<div class="col-sm-4">
<input type="button" class="btn btn-primary btn-lg btn-block btn-bg2" value="Option" name="category-editor-btn" id="category-editor-btn">
</div>
</div>
</div>
</div>
To get the width you need to set the button and the div it is in to have 100% width:
.btn, .input-group {
width: 100%;
}
For the height you can use css and scale the height with the viewport size using vw in css or, if you're willing, you could use jquery to make the height directly proportional to the width:
$(document).ready(btnHeight);
$(window).on('resize', btnHeight);
function btnHeight() {
var width = $('.btn').width();
$('.btn').css('height', width*0.8);
};
To scale the font size you could use vw or just use media queries.
http://www.bootply.com/atAkVSnhQc