I'm trying to make an table with an auto overflow, but that doesn't seem to work.
What I have now:
<div class="panel-group col-sm-offset-1 col-sm-10">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-folder-open-o fa-fw"></i>
<strong>Chatbox</strong>
</div>
<div id="forum4" class="panel-collapse collapse in" style="height:248px;">
<div class="table-responsive">
<table class="table table-hover" style="overflow:auto;max-height:248px;">
<thead>
<tr>
<th style="width:5%"></th>
<th style="width:81%;"></th>
<th style="width:5%;"></th>
<th style="width:8%;"></th>
</tr>
</thead>
<tbody>
<tr>
<td><b>Robin</b></td>
<td>Hier komt dan het bericht :D</td>
<td class="text-right"><small><i class="fa fa-warning" style="color: #CA2B2B;"></i></small></td>
<td class="text-right"><small>16 aug 18:51</small></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
That gives me the perfect thing I want, except when it needs an overflow.
Because when it needs an overflow, it just keeps going, without any overflow.
When I add display:block to the table then it does have an overflow (auto) but the table is shorter (http://prntscr.com/85c09y). That is the problem I want to be fixed, that the table looks like this: http://prntscr.com/85c1u6
I want to have overflox y to be fixed, not overflow x!
UPDATE:
The red outline is the table, the blue dashed outline is the div containing the table, and the black dotted outline is the rest of the layout.
<div class="panel-group col-sm-offset-1 col-sm-10">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-folder-open-o fa-fw"></i>
<strong>Chatbox</strong>
</div>
<div id="forum4" class="panel-collapse collapse in" style="height:248px;">
<div class="table-responsive" style="display:block;overflow:auto;max-height:248px;">
<table class="table table-hover">
<thead>
<tr>
<th style="width:5%"></th>
<th style="width:82%;"></th>
<th style="width:5%;"></th>
<th style="width:8%;"></th>
</tr>
</thead>
<tbody>
<tr>
<td><b>Robin</b></td>
<td>Hier komt dan het bericht :D</td>
<td class="text-right"><small><i class="fa fa-warning" style="color: #CA2B2B;"></i></small></td>
<td class="text-right"><small>16 aug 18:51</small></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
Fix is the code above.
The style="display:block;overflow:auto;max-height:248px;" needed to be standing in the table-responsive class, not the table table-hover class
Related
I am trying to make something like this in Bootstrap 4, setting the columns of table in pixels, with fixed values, forcing the horizontal scroll inside the card, but is not working. The columns don't have the size I want. The columns sizes are going to be same for all devices.
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<table class="table-sm table-hover table-bordered text-center">
<thead>
<tr class="text-uppercase font-size-1">
<th width="500px" class="font-weight-medium"></th>
<th width="500px" class="font-weight-medium">produto</th>
<th width="500px" class="font-weight-medium">status</th>
<th width="500px" class="font-weight-medium">sku</th>
<th width="500px" class="font-weight-medium">preço</th>
<th width="500px" class="font-weight-medium">estoque</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
What am I doing wrong?
It does seem to be working here is the example code
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<table class="table-sm table-hover table-bordered text-center">
<thead>
<tr class="text-uppercase font-size-1">
<th style="width:100px" class="font-weight-medium">first</th>
<th style="width:200px" class="font-weight-medium">produto</th>
<th style="width:300px" class="font-weight-medium">status</th>
<th style="width:400px" class="font-weight-medium">sku</th>
<th style="width:500px" class="font-weight-medium">preço</th>
<th style="width:600px" class="font-weight-medium">estoque</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
you need to put correct inline styles tag
<th style="width:500px;">
This is my problem
As u see, i dont know why the table get that format inside the card.
I need the table to be centered or at least not show that blank space that shows at this time. ... this is my code(im using angular 6)
<div class="row">
<div class="col-md-6">
<div class="header">
<h4 style="padding:10px" class="title">Dispositivo de Ejecucion</h4>
</div>
<div>
<table class="table table-bordered table-condensed table-responsive ">
<thead class="thead-dark">
<tr>
<th>Marca</th>
<th>Sistema Operativo</th>
<th>Version</th>
<th>Modelo</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{dispositivoCdp[0].nombredispositivo}}</td>
<td>{{dispositivoCdp[0].sistema_operativo}}</td>
<td>{{dispositivoCdp[0].version}}</td>
<td>{{dispositivoCdp[0].modelo}}</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-md-6 justify-content-center">
<div class="header">
<h4 style="padding:10px" class="title">Tiempo de Ejecucion</h4>
</div>
<table class=" table table-bordered table-responsive ">
<thead class="thead-dark">
<tr>
<th>Inicio</th>
<th>Fin</th>
<th>Duracion</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{dispositivoCdp[0].nombredispositivo}}</td>
<td>{{dispositivoCdp[0].sistema_operativo}}</td>
<td>{{dispositivoCdp[0].version}}</td>
</tr>
</tbody>
</table>
</div>
</div>
Have any suggestion of what im doing wrong? i try to use table-sm inside the table class but i dont geet any results
Use this
<table class="table table-bordered table-condensed table-responsive" style="display:table">
Try to delete "table-responsive" in your class.
I think that will solve your problem.
The problem in your code is the structure, to make a table "responsive", in Bootstrap 4, you have to insert it inside a <div> with table-responsive class, not in the table classes.
Esample:
<div class="table-responsive">
<table class="table">
...
</table>
</div>
Read the docs: https://getbootstrap.com/docs/4.6/content/tables/#responsive-tables
I cant seem to get this right, i made a divider through css divs and it shows on page but when in print the lines i made doesnt show..what other options should i do? im running out of ideas, what am i doing wrong how can i achieve this
here is what i want ot achieve
heres my css
heres the print preview
page code:
<div id="page-wrapper">
<div class="row">
<div class="col-md-12">
<div class="panel-body">
<p style="text-align:center;"><b>PROPERTY ACKNOWLEDGEMENT RECEIPT</b></p>
<p style="text-align:right;">Control No.</p>
<div class="row">
<div class="col-md-16">
<table class="table table-hover table-striped table-bordered table-condensed" class="">
<thead>
<tr>
<th style="text-align:center;">Quantity</th>
<th style="text-align:center;">Unit</th>
<th style="text-align:center;">Description</th>
<th style="text-align:center;">Unit Value</th>
<th style="text-align:center;">Property No.</th>
</tr>
</thead>
<tbody>
<tr>
<td>12</td>
<td>bucket</td>
<td style="font-size:12px;">oremloremloremloremloremloremloremloremloremlorem</td>
<td>2</td>
<td>1</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<hr style="background-color:black;"> NOTE:
<div style="height:2px;width:100%;background-color:black;"></div>
<div style="width:2px;height:100px;background-color:black;margin:0px auto;"></div>
</div>
</div>
</div>
$(document).ready(function() {
$('#dataTables-example').DataTable({
responsive: true
});
});
I'm trying to get a button into a panel-heading section, but I can't get it to display on the same line. I've managed to get it centered with help of some of the questions on StackOverflow where others asked about a button on the right of the header, but adding the button in seems to make the header taller.
I've got an example showing the difference Bootply
Code
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="panel panel-default" ng-init="getApplications()">
<div class="panel-heading clearfix">
<b>Title has space below</b>
<div class="btn-group pull-right">
new
</div>
</div>
<div class="panel-body">
<!-- table -->
<table class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th>Name</th>
<th>Last Release Date</th>
<th>Orders</th>
<th>Downloads</th>
<th>Activations</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="app in apps">
<td>{{app.columns.name}}</td>
<td>{{app.lastReleaseDt}} </td>
<td>{{app.totalOrders}}</td>
<td>TODO </td>
<td>{{app.totalActivations}}</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-default" ng-init="getApplications()">
<div class="panel-heading clearfix">
<b>Title has no space</b>
</div>
<div class="panel-body">
<!-- table -->
<table class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th>Name</th>
<th>Last Release Date</th>
<th>Orders</th>
<th>Downloads</th>
<th>Activations</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="app in apps">
<td>{{app.columns.name}}</td>
<td>{{app.lastReleaseDt}} </td>
<td>{{app.totalOrders}}</td>
<td>TODO </td>
<td>{{app.totalActivations}}</td>
</tr>
</tbody>
</table>
</div>
</div>
Does anybody have any ideas why adding a button or button group to the panel heading increases the height? Any tips on getting the height to what it was before the button?
because you are using a btn-sm (for small-devices) if you use btn-xs (for extra-small devices) that space will go away due to having a smaller padding
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="panel panel-default" ng-init="getApplications()">
<div class="panel-heading clearfix">
<b>Title has space below</b>
<div class="btn-group pull-right">
new
</div>
</div>
<div class="panel-body">
<!-- table -->
<table class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th>Name</th>
<th>Last Release Date</th>
<th>Orders</th>
<th>Downloads</th>
<th>Activations</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="app in apps">
<td>{{app.columns.name}}</td>
<td>{{app.lastReleaseDt}} </td>
<td>{{app.totalOrders}}</td>
<td>TODO </td>
<td>{{app.totalActivations}}</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-default" ng-init="getApplications()">
<div class="panel-heading clearfix">
<b>Title has no space</b>
</div>
<div class="panel-body">
<!-- table -->
<table class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th>Name</th>
<th>Last Release Date</th>
<th>Orders</th>
<th>Downloads</th>
<th>Activations</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="app in apps">
<td>{{app.columns.name}}</td>
<td>{{app.lastReleaseDt}} </td>
<td>{{app.totalOrders}}</td>
<td>TODO </td>
<td>{{app.totalActivations}}</td>
</tr>
</tbody>
</table>
</div>
</div>
I have found something unusual and was wondering if this is intentional behaviour and if there is a fix for this. I would ideally like to stay within bootstrap without having to specify specific widths.
I am using twitter bootstrap to format a table. However when there is a table with no data the column widths are different to a table with data, i.e. a body with rows.
I have created a jsFiddle to demo this. jsFiddle
Here is the html.
<div class="col-md-10 col-md-offset-1">
<div class="col-md-12 category-header"><span class="">Turbo</span></div>
<div class="col-md-12 no-padding">
<div class="table-responsive">
<table class="table no-margin">
<thead>
<tr>
<th class="text-left col-md-1">Part No.</th>
<th class="text-left col-md-3">Description</th>
<th class="text-center col-md-3">Notes</th>
<th class="text-center col-md-2">Dates</th>
<th class="text-center col-md-1">Stock</th>
<th class="text-right col-md-1">RRP</th>
<th class="col-md-1"></th>
</tr>
</thead>
<tbody>
<tr>
<td class="col-md-1">ISTB10768R</td>
<td class="col-md-3">REMANUFACTURED TURBO</td>
<td title="" class="col-md-3 text-center"></td>
<td class="col-md-2 text-center"></td>
<td class="col-md-1 text-center">
<i title="" data-placement="top" data-toggle="tooltip" class="fa fa-check amber black-tooltip" data-original-title="Less than three units in stock"></i>
</td>
<td class="col-md-1 text-right">£370.00</td>
<td class="col-md-1 text-right">
<span data-part-number="ISTB10768R" data-part-id="564" href="#" class="glyphicon glyphicon-shopping-cart add-to-cart-btn pink " title="Add To Cart ">Add</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-md-12 category-header"><span class="">Gear Boxes</span></div>
<div class="col-md-12 no-padding">
<div class="table-responsive">
<table class="table no-margin">
<thead>
<tr>
<th class="text-left col-md-1">Part No.</th>
<th class="text-left col-md-3">Description</th>
<th class="text-center col-md-3">Notes</th>
<th class="text-center col-md-2">Dates</th>
<th class="text-center col-md-1">Stock</th>
<th class="text-right col-md-1">RRP</th>
<th class="col-md-1"></th>
</tr>
</thead>
<tbody/>
</table>
<div class="missing-parts">Please call the sales team for price and availability</div>
</div>
</div>
</div>
I am sorry but there is a problem in the code you provided(specifically in the second table), perhaps a typo. Which is causing the overflow.
Second table code you provided
<table class="table no-margin">
<thead>
<tr>
<th class="text-left col-md-1">Part No.</th>
<th class="text-left col-md-3">Description</th>
<th class="text-center col-md-3">Notes</th>
<th class="text-center col-md-2">Dates</th>
<th class="text-center col-md-1">Stock</th>
<th class="text-right col-md-1">RRP</th>
<th class="col-md-1"></th>
</tr>
</thead>
<tbody/>
</table>
<div class="missing-parts">Please call the sales team for price and availability</div>
As you can see the <tbody/> is wrong. There is no starting <tbody> tag & the closing tag should be </tbody>. Also there the missing-parts in nowhere inside the table body. It is outside the table body and that's why the weird behavior.
I have provided the correct code below. Here is the updated Fiddle. Works fine now.
Corrected table code
<table class="table no-margin">
<thead>
<tr>
<th class="text-left col-md-1">Part No.</th>
<th class="text-left col-md-3">Description</th>
<th class="text-center col-md-3">Notes</th>
<th class="text-center col-md-2">Dates</th>
<th class="text-center col-md-1">Stock</th>
<th class="text-right col-md-1">RRP</th>
<th class="col-md-1"></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="missing-parts">Please call the sales team for price and availability</div>
</td>
</tr>
</tbody>
</table>
Very important thing to note here is that, even though you have not specified any number of data columns under the first <tr>, it automatically assigns the <td> values to its respective <th>s.
In other words. If you mention only one <td>, it will automatically become the data of the first header ie. "Part No.". Which also means the the width of the data takes the width of the header it corresponds to(just like the top table). Try adding another <td> inside the same table row, you will understand.