I am trying to create a page header / tool bar. This in an existing theme and there is a DIV at the top where this will reside. The basic premise is on the left a H2 title then on the right a bunch of bootstrap elements (search form, bottons, dropdowns etc.
I have tried all kinds of block, inline-block vertical-align etc. I can get the H2 to pull left and the toolbar to pull right but the toolbar elements all pull up to the top of the container div. I just want a clean looking layout with all the elements aligned along their horizontal axis.
I think the pull-right may be part of the problem. That seems to pull the right div up to the top.
Here is a Bootply link: http://www.bootply.com/BPucyP8mpk
<div class"container">
<div id="left">
<h2 class="">Title</h2>
</div>
<div id="right">
<form class="form form-horizontal">
<input type="text" placeholder="search field" class="form-control">
<button type="submit" class="btn">search</button>
</form>
<button class="btn btn-default">Button</button>
<div class="btn-group">
<button class="btn">Left</button>
<button class="btn">Middle</button>
<button class="btn">Right</button>
</div>
<div class="btn-group"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Dropdown<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Choice1
</li>
<li>Choice2
</li>
<li>Choice3
</li>
<li class="divider"></li>
<li>Choice..
</li>
</ul>
</div>
</div>
</div>
UPDATE:
Here is the computed CSS that wraps the header I am trying to format:
border-bottom-width: 1px;
border-top-color: rgb(103, 106, 108);
border-top-style: none;
border-top-width: 0px;
box-sizing: border-box;
color: rgb(103, 106, 108);
display: block;
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 13px;
height: 70px;
line-height: 18px;
margin-left: -15px;
margin-right: -15px;
padding-bottom: 12px;
padding-left: 20px;
padding-right: 20px;
padding-top: 0px;
width: 1318px;
This is from my custom theme I have installed. This is the computed CSS from this wrapper div:
<div class="row wrapper border-bottom white-bg page-heading">
</div>
UPD:
The most suitable method for this task is use Flexbox
Check it out: http://www.bootply.com/CtVmUbzrlr
<div class="row">
<div id="left" class="col-sm-3 col-md-5">
<h2 class="">Title</h2>
</div>
<div id="right" class="col-sm-9 col-md-7">
<form class="form form-horizontal">
<div class="input-group">
<input type="text" placeholder="search field" class="form-control">
<span type="submit" class="input-group-addon">search</span>
</div>
</form>
<button class="btn btn-default">Button</button>
<div class="btn-group">
<button class="btn">Left</button>
<button class="btn">Middle</button>
<button class="btn">Right</button>
</div>
<div class="btn-group"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Dropdown<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Choice1
</li>
<li>Choice2
</li>
<li>Choice3
</li>
<li class="divider"></li>
<li>Choice..
</li>
</ul>
</div>
</div>
</div>
.row{
border: 1px solid #000;
}
#right{
display: flex;
align-items: center;
height: 66px;
justify-content: flex-end;
}
.input-group{
width: 200px;
}
Check this out:
<div class="col-lg-4">
<h2 class="">Title</h2>
</div>
<div class="col-lg-8">
<div class="row">
<form class="form form-horizontal">
<div class="col-lg-8">
<input type="text" placeholder="search field" class="form-control">
</div>
<div class="col-lg-4">
<button type="submit" class="btn btn-block">search</button>
</div>
</form>
</div>
<div class="row">
<div class="col-lg-12">
<button class="btn btn-default">Button</button>
<div class="btn-group">
<button class="btn">Left</button>
<button class="btn">Middle</button>
<button class="btn">Right</button>
</div>
<div class="btn-group"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Dropdown<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Choice1
</li>
<li>Choice2
</li>
<li>Choice3
</li>
<li class="divider"></li>
<li>Choice..
</li>
</ul>
</div>
</div>
</div>
</div>
you can check bootply also : http://www.bootply.com/LmGjZM6fHH
You need to manage your layout with the col-md-*
This is just for the demo, you can arrange with you own way
What about utilizing the navbar component from bootstrap?
http://getbootstrap.com/components/#navbar
I think the example here pretty much sums up your needs.
Basically I've added classes navbar-btn to the buttons, and navbar-form to the form to get them to align properly. I added the class navbar-right to both the form and the group of buttons.
http://www.bootply.com/IySnkX2ioK
Edit: The navbar-default class was just added to outline the bounds of the navbar, not part of the solution.
First thing is that if you want to have your search box on left - place it first and then button group with dropdown. Second, don't place navbar-rigth inside another navbar-rigth. And the last thing - just wrap your right-side elements in one div and add to it a little padding
Updated link
Related
Apologies)
I'm struggling to find a solution to placing two buttons in a column (or two columns?) aligned to a text box to the left of them. I've done this by creating a rect within a colunm then adding the buttons (aligned) floating to the right. Looks fine in a desktop screen but once sized down to mobile the buttons (not being in columns) fall apart. I've attached a screenshot of the page: one row has an attempt but the buttons are placed over the existing column (text box) in the row. It's quite possibly staring me in the face but I can't see it!
Here's a snippet for the row and column:
<div class="row">
<div class="col-8 col-md-6 white-rect mr-4 ">
<ul>
<li>
Book flights.
</li>
</ul>
<button type="button" class="btn my-primary btn-sm my-small-btn">COMPLETE</button>
<button type="button" class="btn my-primary2 btn-sm my-small-btn"> DELETE </button>
</div>
</div>```
And here's the code for the the row with the buttons that are aligned in desktop but are effectively floating outside a column:
```<div class="row">
<div class="col-8 col-md-6 white-rect mr-4">
<ul>
<li>
Reschdule Twitter Meeting.
</li>
</ul>
</div>
<button type=".button" class="btn my-primary btn-sm my-small-btn">COMPLETE</button>
<div class="col-sm-1 col-xs-1 col-md-1 col-lg-1"></div>
<button type=".button" class="btn my-primary2 btn-sm my-small-btn"> DELETE </button>
</div>
Many thanks.
you might need to adjust the numbers, but something like this is how I would do it:
.grid {
display: grid;
grid-gap: 12px;
grid-template-columns: 1fr max-content;
}
#media screen and (min-width: 768px) {
.grid {
grid-gap: 24px;
grid-template-columns: minmax(200px, 1fr) minmax(max-content, 1fr);
}
}
.input {
width: 100%;
}
<section class="grid">
<div class="input-container">
<input type="text" class="input">
</div>
<div class="buttons-container">
<button class="button">complete</button>
<button class="button">delete</button>
</div>
<div class="input-container">
<input type="text" class="input">
</div>
<div class="buttons-container">
<button class="button">complete</button>
<button class="button">delete</button>
</div>
<div class="input-container">
<input type="text" class="input">
</div>
<div class="buttons-container">
<button class="button">complete</button>
<button class="button">delete</button>
</div>
<div class="input-container">
<input type="text" class="input">
</div>
<div class="buttons-container">
<button class="button">complete</button>
<button class="button">delete</button>
</div>
</section>
Im working on a section on a webpage, using bootstrap but cant keep filter on same line. Ive tried a few ways, currently trying columns, tried divs inline, still not lining up correctly.
div class="col-lg-12">
<div class="row">
<div class="col-lg-10">
<div class="rev-search" style="overflow: hidden; padding-right:.5em;" >
<input type="text" style="width: 80%;" id="rev-search" placeholder="Search" autofocus="" />
<span><i class="fa fa-search"></i></span>
</div>
</div>
<div class="col-lg-2">
<div class="dropdown pull-right">
<button class="btn btn-default dropdown-toggle" style="float: right;" type="button" id="group_filter" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"><?php echo $text_filter_group;?><span class="caret"></span></button>
<ul class="dropdown-menu" aria-labelledby="group_filter">
<?php
foreach ($customer_groups as $group){
echo '<li>'.$group['name'].'</li>';
}
?>
</ul>
</div>
</div>
</div>
I believe it's because there is padding on the col-lg-10 and col-lg-2. Add this to your css to remove the padding which is pushing your drop down to the next row.
.col-lg-10, .col-lg-2 {
padding: 0;
}
Following the Bootstrap documentation, please use lg (for larger desktops).
Also try wrapping your row in a fluid container.
<div class="container-fluid">
<div class="row">
</div>
</div>
I have a problem when I use inline-form the input text does not take all the space.
I am aware of that information, but I am a bootstrap beginner.
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.
Cordially
<div class="panel panel-primary">
<div class="panel-heading"><h4>Search Options</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 role="separator" class="divider"></li>
<li>Marketplaces</li>
</ul>
</div>
</div>
<div class="form-group">
<input class="form-control" type="text"
value="" id="filter_id" placeholder="Put your filter here">
<button type="button" class="btn btn-default"> Filtrer </button>
</div>
</form>
</div>
</div>
According to Docs
May require custom widths
Inputs and selects have width: 100%; applied by default in Bootstrap.
Within inline forms, we reset that to width: auto; so multiple
controls can reside on the same line. Depending on your layout,
additional custom widths may be required.
EDIT
as per your comment:
the input text take the rest of space. I want inline all the elements
in a single row and if a space is left the input text should take it
use flexbox
/* !important ONLY USED FOR SNIPPET */
.form-inline {
display: flex
}
.flex {
flex: 1;
display: flex !important
}
.flex input {
flex: 1 !important
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="panel panel-primary">
<div class="panel-heading">
<h4>Search Options</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 role="separator" class="divider"></li>
<li>Marketplaces</li>
</ul>
</div>
</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-default"> Filtrer </button>
</div>
</form>
</div>
</div>
Add a container as a 'context' in your markup and then use it to override your css in this specific context :
<div class="special-form">
<!-- form -->
</div>
CSS
.special-form .panel .form-control {
width: 100%;
}
I am trying to align 7 items in a grid layout so that each element is fixed in it's place currently I am able to achieve like below screenshot. Here is the plunker for the same code (but some how it does not look good on plunker).
The problem in my current state is minutes is wrapped to 2nd line. Also how can I utilise extra space from Agent: label area and Reset button area so that the space gets utilised?
Code
<div class="row">
<div class="col-md-1" style="padding-right:0px; padding-left:0px; margin-top:5px">
<div ng-show="!loadinga">
<b>Agent: </b>
</div>
</div>
<div class="col-md-2" style="padding-left:0px;">
<div class="dropdown " ng-show="!loadinga">
<button class="btn btn-default btn-block dropdown-toggle whiteDropdown" ng-disabled="loading" style="background-color: #fff; border-color: #C3C3C3" type="button" id="dropdownMenu1" aria-expanded="true">
{{dropDownTitle}}
<span class="caret"></span>
</button>
<ul class="dropdown-menu scroll-menu nav" role="menu" aria-labelledby="dropdownMenu1">
<li ng-repeat="agent in agentListData">
<a role="menuitem" href="#" ng-click="">{{agent}}</a>
</li>
</ul>
</div>
</div>
<div class="col-md-2" style="padding-left:0px;">
<div class="dropdown " ng-show="!loadinga">
<button class="btn btn-default btn-block dropdown-toggle whiteDropdown" ng-disabled="loading" type="button" id="dropdownMenu2" aria-expanded="true">
{{dropDownAllTaskStatusTitle}}
<span class="caret"></span>
</button>
<ul class="dropdown-menu scroll-menu nav" role="menu" aria-labelledby="dropdownMenu2">
<li ng-repeat="task in taskStatusListData">
<a role="menuitem" href="#" ng-click="">{{task.title}}</a>
</li>
</ul>
</div>
</div>
<div class="col-md-2" style="padding-right: 0px; padding-left:0px;">
<div ng-show="!loadinga">
<input id="autoComplete" ng-model="selected" typeahead="task.name for task in taskList | filter:$viewValue | limitTo:20" class="form-control" typeahead-on-select="" placeholder="Search Tasks" typeahead-focus-first="true" ng-disabled="loading" type="text" ng-blur="" />
</div>
</div>
<div class="col-md-2 divGridText" ng-show="!loadinga" style="padding-right: 0px; padding-left:0px; margin-right:0px" align="right">
<input ng-model="isChecked" ng-click="checkboxClicked(isChecked)" ng-disabled="loading" type="checkbox" />
<label for="excludeMinutesStep" style="font-weight:normal">Exclude tasks running < </label>
<input id="excludeMinutesStep" min="0" max="10" ng-disabled="!isChecked || loading" ng-model="excludeValue" ng-change="" size="2" style="width:40px" type="number" /> minutes
</div>
<div class="col-md-2 divGridText" ng-show="!loadinga" style="padding-right: 0px; padding-left:0px;" align="centr">
<input id="datalabels" ng-model="isLabelShowChecked" ng-click="" ng-disabled="loading" type="checkbox" />
<label for="datalabels" style="font-weight:normal;">Show Task Labels</label>
</div>
<div class="col-md-1 divGridImage" ng-show="!loadinga" align="center" style="padding-right: 0px; padding-left:0px;">
<button style="margin-left:3px" class="btn btn-custom" ng-click="">Reset</button>
</div>
</div>
Update
Or is there a way to keep Agent: label and drop down in same line without giving separate div with col-md-1 class to label?
Need something like below screenshot
Right so my attempts at solving this are below, I'm not going to give you the same body of text because you can review that in the previous post.
Here is the completed grid with all the parts you have requested, it's also laid out better. (Its not really device friendly as requested).
I updated the example to work correctly
Code:
<head>
<script data-require="jquery#*" data-semver="2.1.4" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script data-require="angular.js#1.x" data-semver="1.4.3" src="https://code.angularjs.org/1.4.3/angular.js"></script>
<script data-require="ui-bootstrap#*" data-semver="0.13.0" src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.13.0.min.js"></script>
<link data-require="bootstrap-css#*" data-semver="3.3.1" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
<link rel="stylesheet" href="style.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.2/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body ng-app="myApp" ng-controller="MainController">
<div class="container-fluid">
<div class="row">
<div class="hidden-xs col-sm-2 sidebar">
<div class="sidebar-nav" style="height:100% !important;min-height: 100% !important">
<div class="navbar navbar-custom" role="navigation">
<ul class="nav recommendation-nav">
<li class="active">
<img style="padding-right: 5px" /> Side bar
</li>
<li >
<img style="padding-right: 5px" />Side bar
</li>
<li >
<img style="padding-right: 5px" />Side bar
</li>
<li >
<img style="padding-right: 5px" />Side bar 1
</li>
<li >
<img style="padding-right: 5px" />Side bar 2
</li>
<li >
<img style="padding-right: 5px"/>Side bar 3
</li>
</ul>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-8 col-sm-offset-1 report-area">
<div class="panel panel-default">
<div class="panel-body">
<div class="row">
<div class="col-xs-12 col-sm-2">
<div class="dropdown" ng-show="!loadinga">
<button class="btn btn-default btn-block dropdown-toggle whiteDropdown" ng-disabled="loading" style="background-color: #fff; border-color: #C3C3C3" type="button" id="dropdownMenu1" aria-expanded="true">
{{dropDownTitle}}
<span class="caret"></span>
</button>
<ul class="dropdown-menu scroll-menu nav" role="menu" aria-labelledby="dropdownMenu1">
<li ng-repeat="agent in agentListData">
<a role="menuitem" href="#" ng-click="">{{agent}}</a>
</li>
</ul>
</div>
</div>
<div class="col-xs-12 col-sm-2">
<div class="dropdown " ng-show="!loadinga">
<button class="btn btn-default btn-block dropdown-toggle whiteDropdown" ng-disabled="loading" type="button" id="dropdownMenu2" aria-expanded="true">
{{dropDownAllTaskStatusTitle}}
<span class="caret"></span>
</button>
<ul class="dropdown-menu scroll-menu nav" role="menu" aria-labelledby="dropdownMenu2">
<li ng-repeat="task in taskStatusListData">
<a role="menuitem" href="#" ng-click="">{{task.title}}</a>
</li>
</ul>
</div>
</div>
<div class="col-xs-12 col-sm-2">
<div ng-show="!loadinga">
<input id="autoComplete" ng-model="selected" typeahead="task.name for task in taskList | filter:$viewValue | limitTo:20" class="form-control" typeahead-on-select="" placeholder="Search Tasks" typeahead-focus-first="true" ng-disabled="loading" type="text"
ng-blur="" />
</div>
</div>
<div class="col-xs-12 col-sm-4 divGridText" ng-show="!loadinga">
<input ng-model="isChecked" ng-click="checkboxClicked(isChecked)" ng-disabled="loading" type="checkbox" />
<label for="excludeMinutesStep" style="font-weight:normal">Exclude tasks running < </label>
<input id="excludeMinutesStep" min="0" max="10" ng-disabled="!isChecked || loading" ng-model="excludeValue" ng-change="" size="2" style="width:40px" type="number" /> minutes
</div>
<div class="col-xs-12 col-sm-1 divGridText" style="width:9.33%" ng-show="!loadinga" >
<input id="datalabels" ng-model="isLabelShowChecked" ng-click="" ng-disabled="loading" type="checkbox" />
<label for="datalabels" style="font-weight:normal;">Task Labels</label>
</div>
<div class="col-xs-1 col-sm-1 divGridImage" ng-show="!loadinga">
<button style="margin-left:3px" class="btn btn-custom" ng-click="">Reset</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Preview:
Your parent divs (the columns) should be set to 0 padding and 0 margin, and the childs should have whatever padding/margin you want. This prevents an overflow.
For example, if you have 4 columns (which equal to 25% width each) and even one of them has a left or right padding of like 10px, then the 4th column will be pushed to the next line because they are now exceeding the 100% width.
Bad example:
HTML:
<div class="col-1">
//content
</div>
<div class="col-2">
//content
</div>
CSS:
.col-1, .col-2 { width: 50%; display: inline-block; padding-left: 15px }
The above code will have the second column flow to the next line because of that padding-left of 15px, which you also use in your own code.
Good example:
HTML:
<div class="col-1">
<div class="inner-col-1">
//content
</div>
</div>
<div class="col-2">
<div class="inner-col-2">
//content
</div>
</div>
CSS:
.col-1, .col-2 { width: 50%; display: inline-block }
.inner-col-1, .inner-col-2 { padding: 0 15px }
The above code will ensure that your columns are on the same line, and the inner content can now use whatever padding/margins you want because they won't affect the width of the parents.
If you don't need to use the application on another screen size, you could try to align Agent: to the right of his container and the reset button to the left of the container. You could the set negative margins to the row, that would give you more place for your content.
Otherwise, bootstrap gives you the possibility to subdivise each column into 12 new columns, you could try something like this :
<div class="row">
<div class="col-md-6">
<!-- you can put here the 4 first elements as you like, on a 12 columns layout -->
</div>
<div class="col-md-6">
<!-- you have again a 12 columns layout for the 3 lasts elements -->
</div>
</div>
look at http://getbootstrap.com/examples/grid/ in the section "Two columns with two nested columns" for a visual example
Easy but no very attractive solution
<span>minutes</span>
PS: I am not sure I have fully understood your question
I have the following code
html page(part of it)
<div class="container">
<div class="right-page col-md-9">
<div class="row">
<div class="category-item col-md-4">
<form action="/settings/category/2/" method="post" class="form-inline">
<div class="container">
<div class="row input-container">
<div class="form-group">
<div class="col-md-8">
<input class="form-control input-sm col-md-3" type="text" value="KONS ">
</div>
<div class="col-md-3">
<input class="form-control input-sm col-md-3 myColorPicker">
</div>
</div>
</div>
</div>
<div class="container">
<div class="row btn-container">
<button class="btn btn-default btn-sm edit-category">Cancel</button>
<button name="delete" class="btn btn-default btn-sm">Delete</button><input type="submit" name="submit" class="btn btn-default btn-sm" value="Save">
</div>
</div>
</form>
</div>
</div>
</div>
and the css (part of it)
.diagnosis-phrase,
.treatment-phrase,
.category-item{
padding-bottom: 1em;
padding-top: 0.5em;
border: 1px solid black;
margin-bottom: 0.5em;
}
.diagnosis-phrase input[type="text"],
.treatment-phrase input[type="text"],
.category-item input[type="text"]{
margin-bottom:0.5em;
}
.category-item p{
padding-left: 0.5em;
padding-bottom:0.3em;
border-radius:0.5em;
width:50%;
}
The bootply for it. The part of html is the right column of a two column webpage. As you can see inside the div with black border I have two input boxes(For some reason the second appears outside the div with borders but in my working code appears correctly. Maybe because of me providing part of page.). My problem is that the first one is not aligned with the Cancel button. How can I do that using bootstrap classes?
if you use the following styles
.form-group .col-md-8:first-child {padding-left:0;}
It should fix your problem
Or if you just change the col-md-8 class on your div to col-md-pull-8 it should also achieve the same thing