Reputation: 401
Here's the code for a simple data table with some pagination controls styled using bootstrap, and datatables for the grid.
<!DOCTYPE html>
<html>
<head>
<title>Test page, using dataTables</title>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.8/css/dataTables.bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"/>
</head>
<body>
<style>
div.dataTables_info{
padding-top: 0px !important;
}
#id1{
background-color: lightblue !important;
}
div.panel-body{
padding: 0px !important;
}
</style>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
Titulo tabela
</div>
<div class="panel-body">
<table id="tabela" class="table table-bordered table-striped">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Value 1</td>
<td>Value 2</td>
<td>Value 3</td>
</tr>
<tr>
<td>Valor 1</td>
<td>Valor 2</td>
<td>Valor 3</td>
</tr>
<tr>
<td>Value 4</td>
<td>Value 5</td>
<td>Value 6</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/1.10.8/js/jquery.dataTables.min.js"></script>
<script src="http://legacy.datatables.net/extras/thirdparty/ColReorderWithResize/ColReorderWithResize.js"></script>
<script>
(function(){
$('#tabela').DataTable({
"dom": 'Rrt<"row-fluid"<"#id1"<"#a.col-md-4"i><"col-md-4"l><"#b.col-md-4"p>>>'
});
})();
</script>
</body>
</html>
Here's a working fiddle of the code above, and here the result in fullscreen.
The thing is that for desktop-type screens, when in fullscreen the bottom row containing the pagination controls loses the background color. Is there some way of keeping the background for all screen widths?
Upvotes: 0
Views: 863
Reputation: 21725
Bootstrap comes with a clearfix
. A clearfix is used when a parent element contains floated child elements and you want the parent element to take up the content area of the child elements.
Change this:
<div id="id1">
to this:
<div id="id1" class="clearfix">
The .col-md-4
elements are floated to the left. When an element is floated it is taken out of the normal document flow which means, as far as a parent element is concerned, the child elements will not take up any space. So the parent element will have a height of none as the child elements are not taking up any space and as a result you cannot see you background color anymore.
Upvotes: 1
Reputation: 195
/*add*/
table.dataTable{
margin-bottom: 0 !important;
}
#id1{
background-color: lightblue !important;
overflow:hidden; /*add*/
}
http://jsfiddle.net/tnoefud0/4/
Look this code. Add overflow for your id1 and delete bottom margin for table.
Upvotes: 0
Reputation: 6244
The reason why you lose the background is that, on large screens, the contents of #id1
is floated.
You can put a clearfix like this:
#id1:after {
content: " ";
display: block;
height: 0;
clear: both;
overflow: hidden;
visibility: hidden;
}
https://jsfiddle.net/tnoefud0/3/embedded/result/
Upvotes: 1