[英]How to position the DataTables button up to the top right corner of the browser?
我想将我的按钮放在浏览器的右上角。 我尝试了css但它失败了。 我还有其他技术可以将数据表按钮放在浏览器的右上角吗?
脚本:
<style>
div.dt-buttons {
float: right;
margin-left:10px;
}
</style>
<script>
$(document).ready(function() {
var buttonCommon = {
exportOptions: {
format: {
body: function(data, row, column, node) {
return column === 5 ? data.replace(/[$,]/g, '') : data;
}
}
}
};
var table = $('#detailsDataTable').DataTable({
"scrollY": 500,
"scrollX": true,
"paging": false,
"info": false,
"searching": false,
dom: 'Bfrtip',
lengthChange: false,
buttons: [
$.extend(true,
{},
buttonCommon,
{
extend: 'excelHtml5',
text: 'Export to Excel'
})
]
});
table.buttons().container().appendTo('#detailsDataTable_wrapper .col-sm-6:eq(0)');
});
</script>
你可以试试
div.dt-buttons {
position: fixed;
top: 0;
right: 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.