Reputation: 457
I need to add some space between table, table length and table pagination. Like this:enter link description here This is my js code:
$(document).ready(function () {
$('#data-table').dataTable({
bFilter: false,
aoColumnDefs: [
{
bSortable: false,
aTargets: [1, 2],
},
{
'bVisible': false,
aTargets: [4],
},
{
"targets": 0,
"render": function (data, type, full, meta)
{
return '<a href = "@(Url.Action("EmployeeAccount", "Company"))?EmployeeId=' + full[4] + '">' + data + '</a>';
}
},
]
})
});
Html:
<table class="table table-striped table-bordered table-hover little_margin_table" id="data-table" width="100%">
/...
</table>
How can I do it?
Upvotes: 1
Views: 14632
Reputation: 375
If all the CSS tricks fail and you want a right-side margin, you can add a small blank column on the right using:
<th> </th> ... <td> </td>"
It looks a little dodgy, but effectively solves the problem. In some browsers the scroll-bar otherwise covers part of the right-most column in wide tables.
Upvotes: 0
Reputation: 900
You must set margin for table in div wrapper of table, example:
if you have table with id userTables
, use selector #userTables_wrapper
in css to set table margin.Why? see screenshot below:
Datatables auto generate div wrapper with id your_table_id + "_wrapper"
.This wrapper is parent for your table.
Upvotes: 5
Reputation: 22041
Use Datatables Styling to create styles for your datatable or modify your css by own:
table.dataTable {
margin: 20px 0 !important;
}
Upvotes: 1
Reputation: 58900
Use the following CSS rules:
table.dataTable {
margin-top:2em !important;
margin-bottom:2em !important;
}
See this jsFiddle for code and demonstration.
Upvotes: 1
Reputation:
In your CSS:
#data-table {
margin: 20px 0;
}
But, to be honest, your question is lacking any HTML and/or CSS. It's also blatantly non-researched, as adding margins between HTML elements can be understood without posting a question on SO.
In any case, what the CSS does it create a top and bottom margin of 20px
for your table.
Upvotes: 3