I have the following code in HTML, using bootstrap:
<div class="panel-body">
<form class="form-horizontal" role="form">
<div class="container-fluid form-group" ng-repeat="app in allKeys track by $index">
<label for="inputEmail2" class="col-md-4 control-label">{{app}}</label>
<div class="col-sm-6 table-responsive">
<table class="table">
<tr>
<td ng-repeat="app1 in allDesc[$index]"><b> {{app1}}</b> </td>
</tr>
<tr >
<td ng-repeat="app2 in allValues[$index]"> {{app2}} </td>
</tr>
</table>
</div>
</form>
</div>
I have two main problem:
If the text is too long in the label section ({{app}}), the text is continue in the line, and override the text in the table section.
If I minimize the browser windows, the container doesn't get the correct size.
I think that this issues are result of definition in the css, that should adjust the text to the appropriate size of the window/column, but I didn't find any css definition for that.
As mentioned in the comments, your main problem is just a missing closing <div> tag. You haven't closed the container-fluid. You can see it working in this Bootply
I also changed your col-md-4 to col-sm-4, as your table wrapper was using sm definitions, which meant that your label would have broken to full width at 'medium' size and your table would have broken to full width at 'small' size, which caused some layout inconsistencies.
you can try this code :
<div class="panel-body">
<form class="form-horizontal" role="form">
<div class="container-fluid form-group row" ng-repeat="app in allKeys track by $index">
<div class="col-sm-6">
<label for="inputEmail2" class="col-md-4 control-label">{{app}} </label></div>
<div class="col-sm-6 table-responsive">
<table class="table">
<tr>
<td ng-repeat="app1 in allDesc[$index]"><b> {{app1}}</b> </td>
</tr>
<tr >
<td ng-repeat="app2 in allValues[$index]"> {{app2}} </td>
</tr>
</table>
</div>
</form>
</div>
making the width to 100% and splitting the blocks accordingly, will help the browser to display the content in a proper way and remember to close the "div" whenever the content for the div is over. Else, the following content will go with misplacement.
Related
I'm working with bootstrap framework v3 and created 4 tables on a single page. Two in one container.
e.g.
First Container:
<div class="container">
<div class="row">
<div class="col-md-6"> <table> <thead></thead> <tbody></tbody> </table> </div> // first table
<div class="col-md-6"> <table> <thead></thead> <tbody></tbody> </table> </div> // second table
</div>
</div>
Second Container:
<div class="container">
<div class="row">
<div class="col-md-6"> <table> <thead></thead> <tbody></tbody> </table> </div> // third table
<div class="col-md-6"> <table> <thead></thead> <tbody></tbody> </table> </div> // fourth table
</div>
</div>
I'd searched the internet and tried lot of codes but headers of all the four tables on a single page are not fixing right as they should be.
I want all the four headers and captions to be fixed while the body of the table to be scroll-able both vertically and horizontally for a given height and a width.
Working Demo: Go to Plunker and launch preview in a separate window.
I'm writing a web site using bootstrap (3.3.2) with a simple table on one of the pages. I just have a simple header panel in one container, and another content container with a title and table. For some reason, text fills the width of the container, but the table left aligns and only spans the width required by the text within. Anyone have any ideas? I know I can add in a width="100%" to the table, but this should be default bootstrap behaviour...
Cheers
<html>
<head>
<title>Page title</title>
<link type="text/css" rel="stylesheet" href="bootstrap.min.css">
</head>
<body>
<div class="navbar navbar-inverse navbar-static-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="index.html">Home</a>
</div>
<div id="navbar" class="navbar-collapse collapse" >
<ul class="nav navbar-nav">
<li><a class="navbar-brand" href="modules.html">Modules</a></li>
<li><a class="navbar-brand" href="sites.html">Sites</a></li>
<li><a class="navbar-brand" href="search.html">Search</a></li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="page-header">
<h2>Why won't the table align!?</h2>
</div>
<div class="table-responsive">
<table>
<thead>
<th>Head1</th><th>Head2</th><th>Head3</th>
</thead>
<tbody>
<tr>
<td>Body1</td><td>Body2</td><td>Body3</td>
</tr>
<tr>
<td>Body1</td><td>Body2</td><td>Body3</td>
</tr>
<tr>
<td>Body1</td><td>Body2</td><td>Body3</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
It's because you are not following the Bootstrap documentation indications on responsive tables. You have to wrap your table element with .table class in a wrapper <div> with the .table-responsive class, like this:
<div class="table-responsive">
<table class="table">
...
</table>
</div>
NOTE: If you're using bootstrap v4 alpha, even though the documentation says that you can use:
<table class="table table-responsive">
...
</table>
I still had to use the accepted answer to make it fill the container's width:
<div class="table-responsive">
<table class="table">
...
</table>
</div>
The accepted answer is incorrect. Per the docs
Create responsive tables by wrapping any .table in .table-responsive to make them scroll horizontally on small devices (under 768px). When viewing on anything larger than 768px wide, you will not see any difference in these tables.
Then goes on to show proper usage
<div class="table-responsive">
<table class="table">
...
</table>
</div>
You should also have the .table class on the <table>
http://getbootstrap.com/css/#tables-responsive
This solution worked for me:
just add another class into your table element: w-100 d-block d-md-table
so it would be : <table class="table table-responsive w-100 d-block d-md-table">
for bootstrap 4 w-100 set the width to 100% d-block (display: block) and d-md-table (display: table on min-width: 576px)
<div class="table table-responsive w-100 d-block d-md-table">
<table class="table">
---
</table>
</div>
Try to add bootstraps class "table" to the tag.
<table class="table">
<thead>
<th>Head1</th><th>Head2</th><th>Head3</th>
</thead>
<tbody>
<tr>
<td>Body1</td><td>Body2</td><td>Body3</td>
</tr>
<tr>
<td>Body1</td><td>Body2</td><td>Body3</td>
</tr>
<tr>
<td>Body1</td><td>Body2</td><td>Body3</td>
</tr>
</tbody>
</table>
Even responsive tables do not expand to fit the container if the container is large. There is no Boostrap table configuration to make that happen.
The simplest way, if you want to use Bootstrap classes, is to add w-100.
Otherwise, use a single-column grid layout.
Instead of using:
<div class="table-responsive">
you should use:
<table class="table table-responsive">
JSFiddle
In most simple words !!
Create responsive tables by wrapping any .table in .table-responsive
to make them scroll horizontally on small devices (under 768px). When
viewing on anything larger than 768px wide, you will not see any
difference in these tables.
So for your requirement .table and .table-responsive will help you.
I have datatable table usng the rowgrouping plugin. I want to jump rows within groups to the right.
Simply said: .group-item class TRs should be moved lets say 10px to the right. How to do that?
I've tried display:block and than margin-left:10px, but that breaks column widths.
To put a jump on an html <tr> is impossible due to the nature of HTML tables. You'll have to change structure a bit.
Option 1, nest a new table
<style>
.subTable {
margin-left: 10px;
}
</style>
<table>
<tr>
<td>
<table class="subTable">
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
</table>
Option 2 is to use some other kind of structure and emulate a table look:
<style>
.jump-over {
position: relative;
left: 10px;
}
</style>
<div class="table">
<div class="row">
<div class="span1"></div>
<div class="span1"></div>
<div class="span1"></div>
<div class="span1"></div>
<div class="span1"></div>
</div>
<div class="row jump-over">
<div class="span1"></div>
<div class="span1"></div>
<div class="span1"></div>
<div class="span1"></div>
<div class="span1"></div>
</div>
<div class="row">
<div class="span1"></div>
<div class="span1"></div>
<div class="span1"></div>
<div class="span1"></div>
<div class="span1"></div>
</div>
</div>
The other CSS for this should be simple and governed by your individual design. You could use a grid framework to do the row and columns for you, but I wouldn't try to make it responsive as this would break the table emulation.
Both of the previous options will not preserve the original table's column widths; the sub-table will have it's own column widths based on its content and the div's will have to have explicitly set widths to start with.
There is one other very ugly option that I do not recommend: it can be done by inserting an extra <td> as the first child of the row in question, but then all previous first children of the parent table will have to have col-span set to 2 (+1 for each nested table beneath it). You can see why that would be a bad idea.
Disclaimer: this is untested code and is meant merely to illustrate a technique.
I have a table with two columns, the right one contains 3 buttons, those buttons change the content in the other column of the table. I want this table to be positioned at the center top of the page but I can't figure out how to do it.
Here is a screenshot of what I want (the image shows a header too, but it's not important for now)
If it is possible I want the buttons to don't move when the content on the other column changes, but it's not a priority.
I can also change the table with another structure if this will help.
Here is html code:
<div class='main'>
<table class="table">
<tr>
<td>
<input type="button" class="button" value="edit_menu"/><br><br>
<input type="button" class="button" value="edit_desc"/><br><br>
<input type="button" class="button" value="set_push"/>
</td>
<td>
<div id="content">
<div id="edit_menu" display="none" class="form">
here is a simple form
</div>
<div id="edit_desc" display="none" class="form">
here is a second form
</div>
<div id="set_push" display="none" class="form">
here is a third form
</div>
</div>
</td>
</tr>
</table>
</div>
The forms visibility is changed via Javascript when the buttons are pressed.
Try using the below code.
css :
body {margin:0; padding:0;}
.wrapper {width: 500px /* width of your table*/; margin:0 auto;}
html :
<div class="wrapper">
<!-- put your table here -->
</div>
When I resize this fiddle, the input box gets larger when I shrink the screen. Unfortunately on the iPhone, it's going off the screen in my app.
Here is the fiddle: http://jsfiddle.net/v6Bhx/5/embedded/result/ and here is the code:
<div class="row-fluid">
<div class="span6">
<table width="500">
<tr>
<td>
<div class="input-prepend">
<span class="add-on">$</span>
<input type="text" name="fee" value="" class="span6" />
</div>
</td>
</tr>
</table>
</div>
<div class="span6">Test</div>
</div>
Also yes, I realize I am using tables. I am not doing this to format data, it is actually being used for tabular data which happens to have input boxes in it.
Either set a width on slider :
<input style="width:125px;" type="text" name="fee" value="" class="span6" />
or use css
.span6 { width: 125px; }
The reason is the table is changing row widths on page resize
My suggestion is to use table width="100%" .
<div class="row-fluid">
<div class="span6">
<table width="100%">
<tr>
<td>
<div class="input-prepend"> <span class="add-on">$</span>
<input type="text" name="fee" value="" class="span6"
/>
</div>
</td>
</tr>
</table>
</div>
<div span="6">Test</div>
</div>
Setting the table width # 500px will likely cause a problem as the viewpoint shrinks to mobile size. Try removing the table width and see what happens.
Update
I can't picture exactly how you want the final page and table to look, but here are a few additional points you could check.
Regarding the iPhone display issue, make sure that in the head of your page you have:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
I think that specifying a table width of 100% will be invalid HTML5. I doubt that this is the source of your problem, but try something like this in your CSS:
.span6 table{
width:100%;
}
I can see that having the form with an input prepend inside a table is going to be a challenge. If there is no way around this, you have a nesting problem at the moment -- the input.span6 is actually nested inside the another span6 column.
In general, the HTML for a nested grid with fluid rows is:
<div class="row-fluid">
<div class="span6">
<div class="row-fluid"> <!-- start nested grid -->
<div class="span12">
<!-- Form and table details here -->
</div> <!-- end nested span -->
</div> <!-- end nested row -->
</div> <!-- end span6 -->
<div class="span6">
test
</div>
</div>
See the fluid nesting section on http://twitter.github.com/bootstrap/scaffolding.html#gridSystem for full details.
Good luck!