Using Bootstrap3, I have a "toolbar" above a table. The toolbar has a series of input fields and buttons. I need the left/right ends of the toolbar to align with the ends of the table.
I tried to use Bootstrap's column classes to position the various toolbar elements. The positioning seems to be correct when viewed in full screen mode on a typical large (or greater) display.
I am able to align the fields and buttons to the end of the table if I remove the left and right padding from the first and last divs respectively. This is what I'm currently doing and it works. But I was hoping to achieve this without overriding the default styles. I suspect there is a simpler way of doing this that I am missing.
This is a little different than I'm used to since there are several different types of elements in the toolbar.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<div class="container-fluid">
<div class="col-sm-12">
<div class="row">
<div class="btn-toolbar">
<div class="col-sm-2">
<div class="form-group">
<label class="control-label">Start Date</label>
<div>
<input type="text" class="form-control" />
</div>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<label class="control-label">End Date</label>
<div>
<input type="text" class="form-control" />
</div>
</div>
</div>
<div class="col-sm-2">
<label class="control-label"> </label>
<div>
<button type="button" class="btn btn-success">
Get Data
</button>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<div>
<label class="control-label">Search</label>
<input type="search" class="form-control" />
</div>
</div>
</div>
<div class="col-sm-1">
<label class="control-label"> </label>
<div>
<button type="button" class="btn btn-success">
Search
</button>
</div>
</div>
<div class="col-sm-3">
<div class="pull-right">
<label class="control-label"> </label>
<div class="btn-toolbar">
<button type="button" class="btn btn-success">Create
</button>
<button type="button" class="btn btn-danger">
Close
</button>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<table class="table table-condensed table-striped table-bordered">
<thead>
<tr>
<th>Col1</th>
<th>Col2</th>
<th>Col3</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
Any suggestions would be appreciated.
Two elements are extra in your code. One of them is the .btn-toolbar (the one in between .row and Bootstrap grid columns) while the second is .row around the table element.
Wrapping .row around the table is excess because you are not using any columns inside this row. Further remove .btn-toolbar element as well because you have set some custom margin-left here which is causing some misalignment from the left side.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<div class="container-fluid">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-2">
<div class="form-group">
<label class="control-label">Start Date</label>
<div>
<input type="text" class="form-control" />
</div>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<label class="control-label">End Date</label>
<div>
<input type="text" class="form-control" />
</div>
</div>
</div>
<div class="col-sm-2">
<label class="control-label"> </label>
<div>
<button type="button" class="btn btn-success">Get Data</button>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<div>
<label class="control-label">Search</label>
<input type="search" class="form-control" />
</div>
</div>
</div>
<div class="col-sm-1">
<label class="control-label"> </label>
<div>
<button type="button" class="btn btn-success">Search</button>
</div>
</div>
<div class="col-sm-3">
<div class="pull-right">
<label class="control-label"> </label>
<div class="btn-toolbar">
<button type="button" class="btn btn-success">Create</button>
<button type="button" class="btn btn-danger">Close</button>
</div>
</div>
</div>
</div>
<table class="table table-condensed table-striped table-bordered">
<thead>
<tr>
<th>Col1</th>
<th>Col2</th>
<th>Col3</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</tbody>
</table>
</div>
</div>
Related
DEMO JSFiddle
How can I center horizontally all the contents? Especially the contents of the second <td>
Just add margin:auto to row tag to <div class="row" style="margin:auto"> as follows:
https://jsfiddle.net/01rewj56/1/
<div class="container">
<div class="row">
<div class="col-12">
<table class="table table-borderless table-condensed mt-5">
<thead>
<tr>
<th style="text-align:center;">Reference Genome</th>
<th style="text-align:center;">Annovar version</th>
<th style="text-align:center;"></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<select class="form-control" name="referenceGenomeSelect">
<option value="1">hg19</option>
<option value="2">hg38</option>
</select>
</td>
<td>
<div class="form-inline">
<div class="row" style="margin:auto"> <!-- added margin auto -->
<div class="col">
<input type="text" id="annovarVersion" class="form-control" placeholder="Please select a file...">
</div>
<div class="col">
<button class="btn btn-secondary" onclick="document.getElementById('annovarVersionInput').click()">Browse</button>
<input type='file' id="annovarVersionInput" style="display:none" onchange='updateInputText(this.value, -1)'>
</div>
</div>
</div>
</td>
<td>
<button type="submit" class="btn btn-primary" >Save</button>
<button type="submit" class="btn btn-secondary" >Cancel</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
#Cheknow
why you used the table the Bootstrap version 4
https://getbootstrap.com/docs/4.0/components/forms/
Inline
Group checkboxes or radios on the same horizontal row by adding .form-check-inline to any .form-check.
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1">
<label class="form-check-label" for="inlineCheckbox1">1</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="inlineCheckbox2" value="option2">
<label class="form-check-label" for="inlineCheckbox2">2</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="inlineCheckbox3" value="option3" disabled>
<label class="form-check-label" for="inlineCheckbox3">3 (disabled)</label>
</div>
table doesn't fit on the screen. tried with most of the combination but doesn't work.
amateur, help needed.
i don't know whats going wrong maybe some silly mistake and wasn't able to find any mistake
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Generate</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header" >
<a class="navbar-brand" href="index.html"> <img alt="Brand" src="slideshow/img.png" style="height: 40px; display: inline-block; margin-top: -5px"> </a>
</div>
<ul class="nav navbar-nav" >
<li class="active">Home</li>
<li>Generate POR</li>
<li>Update POR</li>
<li>Help</li>
<li>Contact us</li>
</ul>
<form class="navbar-form navbar-right">
<div class="form-group" id="demo">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<form class="navbar-form navbar-right">
<div class="form-group" id="txt1" style="color: aliceblue; margin-top: -5px" >
</div>
</form>
</div>
</nav>
<div class="col-md-8 col-md-offset-2">
<div class="row">
<form>
<div class="col-sm-12">
<div class="row">
<div class="col-sm-6 form-group">
<label>P O Date</label>
<input type="date" class="form-control">
</div>
<div class="col-sm-6 form-group">
<label>Category</label>
<select class="form-control" >
<option>Technology</option>
<option>Business</option>
<option>Development</option>
<option>Process</option>
</select>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="row">
<div class="col-sm-6 form-group">
<label>Location</label>
<select class="form-control" >
<option>Bengaluru</option>
<option>Mumbai</option>
<option>Pune</option>
</select>
</div>
<div class="col-sm-3 form-group">
<label>Type of training</label>
<select class="form-control" >
<option>RBI</option>
<option>PST</option>
<option>Org needs</option>
</select>
</div>
<div class="col-sm-3 form-group">
<label>Venue Details</label>
<select class="form-control" >
<option>Mumbai</option>
<option>Bengluru</option>
<option>Pune</option>
</select>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="row">
<div class="col-sm-6 form-group">
<div class="form-group">
<label>Vendor Address</label>
<textarea placeholder="Vendor Address Here.." rows="3" class="form-control"></textarea>
</div>
</div>
<div class="col-sm-6 form-group">
<div class="form-group">
<label>Billing Address</label>
<br>
Billing Address :<br>
Quinnox Consultancy Services Ltd.;<br>
Unit 170,SDF VI, SEEPZ SEZ,<br>
Andheri(East), Mumbai-400096<br>
</div>
</div>
</div>
</div>
Display of tables isnt good below part is the problemtable doest fit on the screen
<div class="col-sm-12">
<div class="row">
<table class="table table-condensed table-striped table-hover" align="center">
<thead class="thead-inverse">
<tr>
<div class="form-group">
<th>Subject</th>
<th>Faculty</th>
<th colspan="2" align="center">Date</th>
<th>Days</th>
<th>Batch Size</th>
<th>Rate per day</th>
<th>Approx Expected value(INR)</th>
</div>
</tr>
</thead>
<tbody>
<tr>
<div class="form-group">
<td><input type="text"/></td>
<td><input type="text"/></td>
<td><input type="date"/></td>
<td><input type="date"/></td>
<td><input type="text"/></td>
<td><input type="text"/></td>
<td><input type="text"/></td>
<td><input type="text"/></td>
</div>
</tr>
</tbody>
</table>
</div>
</div>
</form>
</div>
</div>
</body>
</html>
you need to wrap the table in div with a class table-responsive and dont wrap it directly to row class
here is demo
If you want to fit the table on the screen keep the table code out of the div which has class "col-md-8 col-md-offset-2"
and if the table is overflowing the screen you can use class table-responsive as parent of table.
What size screen doesn't it fit on? Bootstrap 3 has a .table-responsive class that can be added to the table allows horizontal scrolling on devices smaller than 768px wide. The docs for that are here.
I have a form which search for the country code, name, and a valid date. It has got two buttons named search and cancel. At the bottom of a form it also has four buttons named terminate, add, edit, and delete. When you click add button it should display another that has the following, but I just do not have an idea on how am I gonna make this work.
Here is the html file for both forms:
<div class="container">
<div class="row">
<div class="col-md-4">
<thead>
<hr>
<div class="panel panel-default">
IETA-Admin-Exchange Rate
</div>
</thead>
<div class="panel panel-success">
<div class="table-responsive">
<table class="table table-striped">
<tr>
<th>Code</th>
<th>Rate</th>
<th>Start Date</th>
<th>End Date</th>
</tr>
<tr>
<td>ZAR</td>
<td>1.02</td>
<td>13/10/15</td>
<td>12/11/15</td>
</tr>
<tr>
<td>LUX</td>
<td>1.02</td>
<td>13/10/15</td>
<td>12/11/15</td>
</tr>
<tr>
<td>JPY</td>
<td>1.02</td>
<td>13/10/15</td>
<td>12/11/15</td>
</tr>
<tr>
<td>EEK</td>
<td>1.02</td>
<td>13/10/15</td>
<td>12/11/15</td>
</tr>
<tr>
<td>CAD</td>
<td>1.02</td>
<td>13/10/15</td>
<td>12/11/15</td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-md-8">
<hr>
<p>Search___________________________________________________________________________________________________________________________________________________________</p>
<form class="form-vertical">
<div class="col-md-12">
<div class="form-group">
<label for="code" class="col-md-8 control-label">Code:</label>
<div class="col-md-12">
<input type="text" class="form-control" ng-model="code">
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label for="name" class="col-md-8 control-label">Name:</label>
<div class="col-md-12">
<input type="text" class="form-control" ng-model= "name">
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label for="date" class="col-md-12 control-label">Valid On:</label>
<div class="col-md-6">
<input type="date" class="form-control" ng-model="date">
</div>
</div>
</div>
<div class="jumbotron text-right">
<button ng-click="search()" class="btn btn-active btn-sm">
<span class="glyphicon glyphicon-search">Search</button>
<button ng-click="cancel()" class="btn btn-active btn-sm">
<span class="glyphicon glyphicon-remove"></span>Cancel</button>
</div>
</form>
</div>
</div>
<hr>
<!-- Add html file-->
<!-- end of Add html-->
<div class="jumbotron text-right">
<div class="col-md-12">
<button ng-click="terminateToday()" class="btn btn-active btn-sm">Terminate Today</button>
<button ng-click="add()" class="btn btn-active btn-sm">
<span class="glyphicon glyphicon-plus"></span>Add</button>
<button ng-click="edit()" class="btn btn-active btn-sm">
<span class="glyphicon glyphicon-edit"></span>Edit</button>
<button ng-click="delete()" class="btn btn-active btn-sm">
<span class="glyphicon glyphicon-trash"></span>Delete</button>
</div>
</div>
</div>
<!-- end of Add html-->
Please help!
I am trying to position a well to the center of the page. There are similiar questions on SO, but the code is somewhat different to mine. My HTML is given below:
<div class="container">
<div class="row">
<div class="well col-sm-4" align="center">
<div class="text-center">
<p><h2>Login</h2></p>
</div>
<hr>
<form role="form">
<div class="form-group text-center">
<label for="username">Username</label>
<input type="text" class="form-control" id="username">
</div>
<div class="form-group text-center">
<label for="password">Password</label>
<input type="password" class="form-control" id="password">
</div>
<hr>
<div class="text-center">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="button" class="btn btn-warning">Forgot password</button>
</div>
<hr>
<div class="text-center">
<p>Don't have an account yet? <a>Create one now</a></p>
</div>
</form>
</div>
</div>
</div>
I tried putting the well div inside another div with col-md-12 and other values, but the well did not get centered. Does anyone know how I could center the well in the page?
You could try offsetting columns
Give your columns the class col-sm-offset-4
Like so: <div class="well col-sm-offset-4 col-sm-4">
Example: http://jsfiddle.net/u48v34p7/
<div class="container">
<div class="row">
<div class="col-sm-4 well col-sm-offset-4" align="center">
<div class="text-center">
<p><h2>Login</h2></p>
</div>
<hr>
<form role="form">
<div class="form-group text-center">
<label for="username">Username</label>
<input type="text" class="form-control" id="username">
</div>
<div class="form-group text-center">
<label for="password">Password</label>
<input type="password" class="form-control" id="password">
</div>
<hr>
<div class="text-center">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="button" class="btn btn-warning">Forgot password</button>
</div>
<hr>
<div class="text-center">
<p>Don't have an account yet? <a>Create one now</a></p>
</div>
</form>
</div>
</div>
</div>
Just replace your code here:
<div class="well col-sm-4" align="center">
With this (you can also isolate the style in a CSS class):
<div class="well col-sm-4" style="margin:auto; float:none;">
You could put two dummy divs to make your well centered. I have noticed that you only have one col-sm-4
Try this:
<div class = "col-sm-4"></div>
<div class = "well col-sm-4">
<!-- your content here -->
</div>
<div class = "col-sm-4"></div>
In that way you can have your well centered.
You can also do this
<div class = "well col-md-6 col-md-offset-3">
<!-- content here -->
</div>
To make your well centered on desktop view 1280px and above.
Hi I have an AngularJS aplication created using Grunt bower and yeoman.
I am trying do grunt serve:dist on the application. While minifying some HTML shows error and doesn't minifying even if I do --force
I have some HTML pages in my views.
application.html
<!-- build:js scripts/applicationctrl.js -->
<script src="scripts/controllers/appln.js"></script>
<!-- endbuild -->
<div ng-if="view" id="application"
class="tab-pane active">
<div class="box-header blue-background">
<div class="title">
<div class="icon-edit"></div>
Application Information
</div>
</div>
<form class="form form-horizontal " id="appForm" name="appForm"
ng-submit="saveapplication()" ng-if="update"
style="margin-top: 1%">
<div ng-if="statusMessage!=null"
class="alert {{alertType}} alert-dismissable">
<a class="close" data-dismiss="alert" href="">× </a> <i
class="{{statusIcon}}"></i> {{statusMessage}}
</div>
<div class="groupedColumns"
ng-if="allowed">
<div class="col-sm-6">
<div class="form-group">
<label class="control-label col-sm-4 " for="applicationName">Application
: <span class="required">*</span>
</label>
<div class="col-xs-7 controls">
<input class="form-control input-sm inline-block"
data-rule-required="true" ng-model="application.name"
placeholder="Application Name" required="required" />
</div>
<div class="availability-result">
<i id="loading" class="{{spinnerClass}}"></i> <span
class="{{msgClass}}"></span>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-4 " for="applicationID">Application
ID : </label>
<div class="col-xs-7 controls">
<input class="form-control input-sm"
ng-model="application.applicationId" id="applicationID"
name="applicationID" placeholder="Application ID" />
</div>
</div>
</div>
</div>
</div>
</div>
I have another file in the same views folder.
info.html
<!-- build:js scripts/infoctrl.js -->
<script src="scripts/controllers/info.js"></script>
<!-- endbuild -->
<div class="box bordered-box" ng-if="tabpage.enable">
<div class="box-content box-no-padding">
<div class="responsive-table">
<div class="box-header">
<div class="title icon-truck">Summary</div>
</div>
<div class="form-group col-sm-6 no-margin-bottom">
<label
class="control-label col-sm-5 col-xs-12 input-sm-attr no-padding">Active
: </label>
<div>
<input class"no-padding" type="checkbox" ng-model="info.isActive"
ng-change="enablesave()">
</div>
</div>
<div class="col-xs-2 actions">
<button type="submit" id="infoSaveID"
ng-disabled="savebutton.enable" value="Save"
ng-click="saveInfo()"
class="btn btn-primary icon-ok icon-white">Save</button>
</div>
<div class="scrollable-area" style="padding-top: 5px;">
<table class="table-condensed table table-bordered table-hover">
<thead>
<tr>
<th class="col-size-reduce"
ng-repeat="(key ,value) in infoStatus[0]">{{key}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in infoStatus">
<td class="col-size-reduce" ng-repeat="(key, value) in row">
{{value}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
And I have many files too like this.
When I do grunt serve:dist it minifies the first html page. While it shows error while minifying the info.html page
Warning: dist/views/info.html
Parse Error: <input class"no-padding" type="checkbox" ng-model="info.isActive"
ng-change="enablesave()">
</div>
</div>
<div class="col-xs-2 actions">
<button type="submit" id="infoSaveID"
ng-disabled="savebutton.enable" value="Save"
ng-click="saveInfo()"
class="btn btn-primary icon-ok icon-white">Save</button>
</div>
<div class="scrollable-area" style="padding-top: 5px;">
<table class="table-condensed table table-bordered table-hover">
<thead>
<tr>
<th class="col-size-reduce"
ng-repeat="(key ,value) in infoStatus[0]">{{key}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in infoStatus">
<td class="col-size-reduce" ng-repeat="(key, value) in row">
{{value}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div> Used --force, continuing.
Warning: Cannot read property 'length' of undefined Used --force, continuing.
Why the first one is working fine and the second one shows error? How to solve it?
There is an error in your HTML syntax. At the first line, replace
<input class"no-padding" type="checkbox" ng-model="info.isActive"
ng-change="enablesave()">
By
<input class="no-padding" type="checkbox" ng-model="info.isActive"
ng-change="enablesave()">
And htmlmin will work properly.