Bootstrap4 CSS attribute 'display: none'

Bootstrap4 CSS attribute 'display: none'

mBeiermBeier Posts: 4Questions: 1Answers: 0


in the past I used DataTables with Bootstrap 3, actually im refractoring for Bootstrap 4.

there is a strange behaviour with DataTables and Bootstrap 4.
First it always adds a 'display: none' css property to my table div.

-> this is from my rendered page

<table id="devices" class="table display responsive dataTable no-footer" role="grid" aria-describedby="devices_info" style="width:  557px; display: none;">

if I remove the display: none property manually the table shows up but looks strange .. if I also remove the dataTable class, the table looks like a normal bootstrap 4 table, but the width is not set to 100% to the div.

if I change the 'width: xxx px' property to 100% it has its full width.

I dont actually know where my failure is.

// includes

// My Bootstrap 4 Stylesheet version
<link rel="stylesheet" href="">
// Stylesheet
<link rel="stylesheet" type="text/css" href=""/>

// My jQuery Version
<script src=""></script>
// My Bootstrap Version
<script src=""></script>
<script src=""></script>
// Javascript
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>

// HTML table div

<table id="devices" class="table display responsive">

// table header data

const deviceTHead =
      data: 'name',
      data: 'serial',
      data: 'article',
      data: 'gatewayId',

// table body data

const devicesTdata = [];
for (let i = 0; i < expressData.customerDevices.length; i += 1) {
    name: expressData.customerDevices[i],
    serial: expressData.customerDevices[i].serial,
    article: expressData.customerDevices[i].article,
    gatewayId: expressData.customerDevices[i].settings.gatewayId,

// data example

0: {…}
article: "0000"
gatewayId: "1234"
name: "Testname"
serial: "9876"

// dataTables

const deviceTableOpts = $('#devices').DataTable({
  // searching: false,
  // paging: false,
  responsive: true,
  columns: deviceTHead,
  data: devicesTdata,

Edit: I have the same Problem with your example Bootstrap 4 DataTable (copy&paste)**


  • mBeiermBeier Posts: 4Questions: 1Answers: 0


    I actually can't edit the post anymore but i have to add, when i remove the 'table' class, all data is shown, but without bootstrap css styles.

  • allanallan Posts: 51,422Questions: 1Answers: 7,754 Site admin

    Can you link to a page showing the issue please? This example shows DataTables working with Bootstrap 4 as expected.


  • mBeiermBeier Posts: 4Questions: 1Answers: 0

    The page is local at the moment.

    I also copy&pasted the example on my page, but there is still no table showing up, there is always the css attribute 'display: none' added to the table .. not even to any class, the attribute is only added to this element.

    Element {
        width: 100%;
        display: none;
    table.dataTable {
        clear: both;
        margin-top: 6px !important;
        margin-bottom: 6px !important;
        max-width: none !important;
        border-collapse: separate !important;
    .table {
        width: 100%;
        max-width: 100%;
        margin-bottom: 1rem;
        background-color: transparent;
    table {
        border-collapse: collapse;
    *, ::after, ::before {
        box-sizing: border-box;
    html, body {
        font-family: 'Roboto', sans-serif;
        font-size: 14px;
    body {
        font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
        font-size: 1rem;
        font-weight: 400;
        line-height: 1.5;
        color: #212529;
        text-align: left;
    :root {
        --blue: #007bff;
        --indigo: #6610f2;
        --purple: #6f42c1;
        --pink: #e83e8c;
        --red: #dc3545;
        --orange: #fd7e14;
        --yellow: #ffc107;
        --green: #28a745;
        --teal: #20c997;
        --cyan: #17a2b8;
        --white: #fff;
        --gray: #6c757d;
        --gray-dark: #343a40;
        --primary: #007bff;
        --secondary: #6c757d;
        --success: #28a745;
        --info: #17a2b8;
        --warning: #ffc107;
        --danger: #dc3545;
        --light: #f8f9fa;
        --dark: #343a40;
        --breakpoint-xs: 0;
        --breakpoint-sm: 576px;
        --breakpoint-md: 768px;
        --breakpoint-lg: 992px;
        --breakpoint-xl: 1200px;
        --font-family-sans-serif: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
        --font-family-monospace: SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
    html {
        font-family: sans-serif;
        line-height: 1.15;
        -webkit-text-size-adjust: 100%;
  • mBeiermBeier Posts: 4Questions: 1Answers: 0


    wow, okay I spend so many hours trying to fix this problem.

    window.onload = function () {

    but with this script, the table can't show up.

    thanks for your help allan.

Sign In or Register to comment.