Data tables sizing issue occurring across various web browsers

I've recently encountered an issue with my DataTables not filling 100% of their div width. I'm utilizing Bootstrap and jQuery for this project. Any suggestions or tips to fix this problem?

HTML

 <div class="form-group" style="height: 400px; width: 100%;">
    <div class="row">
     <br>
      <table data-role="table" id="datatables2" class="datatables display ui-responsive form-table" style="width: 100%;"> <!--Beginning Table -->
  <thead>
    <tr>
      <th>Staff</th>
      <th>Comment</th>
      <th>Search</th>
      <th>Priority</th>
    </tr>
  </thead>
  <tbody>  
  </tbody>
 </table> <!-- End Table -->
 </div>

CSS

table {
overflow-x: auto;
display: block;
width: 100% !important;
font-size: 13px;
}

jQuery

    aTable = $('table#datatables2').DataTable({
     scrollX: false,
     retrive: true,
     ordering: false,
     bFilter: false,
     bPaginate: false,
     bInfo: false,
     responsive: true
  });

Links / Scripts:

   <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
   <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.13/r-2.1.1/sc-1.4.2/se-1.2.0/datatables.min.css"/>
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

  <script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.13/r-2.1.1/sc-1.4.2/se-1.2.0/datatables.min.js"></script>

Safari Image

https://i.sstatic.net/Tf8CQ.png

Google Chrome Image

https://i.sstatic.net/dbpfj.png

Answer №1

Make sure to eliminate the following line from the CSS code for the table:

display: block;

By doing this, the layout should resemble the one in Safari's image. Otherwise, follow these steps:

If you desire additional centering, include the following line in the CSS code for th with the sorting_disabled class:

text-align: center;

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Cease the continuous scrolling of the display element now

I'm having trouble with my progressbar animation when scrolling. It seems to run multiple times instead of just once. I apologize if there's an error in my code. Could someone please assist me? This is the code I am using: <div class="demo- ...

What is the best way to modify the styling of my CSS attributes?

I'm currently working with this CSS code: input:checked + .selectablelabel .check { visibility: hidden; } Now, I want to change the visibility property to "visible" using JavaScript. I attempted the following: $(document).on('click', & ...

What is the best way to locate an element with the class name being an email address using jQuery?

Is it possible to locate an element with an email address as the class name, considering that the email address varies? $(document).ready(function(){ //not working getting error var email="<a href="/cdn-cgi/l/email-protection" class="__cf_email__ ...

Can someone help me troubleshoot why my multi-step form is not functioning properly?

I've been working on a multi-phase form, but it's not behaving as expected. I've tried different code variations, but for some reason, it's not functioning properly. After spending two days on it, I'm starting to feel a bit frustra ...

React - the perfect solution for managing dynamic inline styles

When it comes to handling inline styles, there are two scenarios to consider. Which approach is the most effective for 'toggling' CSS properties based on the component state - or is there a better alternative? 1. The first method involves creati ...

Verifying the compatibility of a font with MathJax on untried devices

Within the style sheet of my website, I have implemented the following code: .mi, .mo { font-family: 'Charter', 'MathJax_Math' !important; } Instead of focusing on whether this will always produce satisfactory results for users if ...

Update the CSS of a different element when hovering

Hello to all the jQuery developers out there! I have a question that's fairly simple. I'm trying to change a CSS attribute for an element when I hover over a different element on the page. I've created a fiddle for you to review, and I&apos ...

The issue with CSS right alignment not functioning as expected

My attempt to align text to the right using a CSS rule is not working as expected when applied to a font within a cell. Can anyone help me troubleshoot this issue? Take a look at my code snippet below: CSS: .font1 { font-size: 60px; text-align: ...

Incorporating external plugins with jQuery in Angular 2

My experience with Angular 2 and jQuery has been quite positive. I am eager to incorporate external libraries such as masonry-layout, but I have encountered a frustrating issue: When trying to use jQuery(...).masonry(), I receive an error stating that i ...

AngularJS routing that is tailored to form input

I am trying to create a dynamic html page where the user can input form variables. My goal is to use AngularJS routing to navigate to different URLs based on the form inputs. Does anyone have advice or guidance on how I can achieve this functionality? ...

jquery version 1.8 includes support for case-insensitive searching using the "starts with

Currently seeking a plugin/extension for jQuery's :contains selector that is case insensitive and only matches words starting with the specified text. The goal is to prevent 'account' results when searching for 'count' specificall ...

What is the best way to delete an added element once a DIV has been toggled with JQuery?

I'm facing an issue where I need to add an element to a DIV that has a toggle function. However, every time I click the toggle again after adding the element, the same element is appended once more, resulting in duplicate elements. Upon observation, ...

Tips for adjusting the size of a CSS radio button while ensuring the text remains centered

Uncertain about which part to modify in this radio button code to decrease its size while keeping the text aligned with the inner button. Changes made have shifted the text to the top of the button instead. Can you provide guidance on the necessary adjustm ...

Converting HTML Form Data into CSV with Multiple Rows

I currently have a form that generates a CSV file with data from select elements in the HTML form. The columns in the CSV correspond to the selected options in the form, but I need to extend this functionality to populate multiple rows in the CSV. Expecte ...

Using HTML to execute a JavaScript function that transforms images

The script cutImageUp has been previously discussed on SE in a thread about Shattering image using canvas. However, I have encountered a different issue while attempting to use it. The HTML code I implemented seems to be ineffective, and despite my efforts ...

Is it possible for this solution to be compatible with IE7 and IE6?

Is there a way to enhance this solution for compatibility with IE6 and IE7? http://jsfiddle.net/kirkstrobeck/sDh7s/1/ Referenced from this discussion After some research, I have come up with a practical solution. I've converted it into a new func ...

Using jQuery to retrieve every key value pair from a JSON object?

Recently, I received a JSON data structure: {key:value, key2:value2, key3:value3...} My goal is to iterate over each entry in order to extract its key and value. This way, I can create a new structure like this: {list:[{key:value}, {key2:value2}, {key3: ...

Is there a way to place the icon on the right side of the @mui/Chip component?

Currently, I am working with MUI version 5.15.0. I have a component called Chip, and my goal is to display the icon after the label on the right side. I attempted to use the CSS rule - .MuiChip-icon{ order:1 }, but it resulted in too much spacing. Additio ...

Is it possible to execute jQuery or Angular functions using WWW::Mechanize::Firefox?

When attempting to run jQuery/Angular calls using WWW::Mechanize::Firefox's eval_in_page, I am encountering errors that suggest a scope issue. For example, if I try to execute the following code: angular.element(document.getElementsByClassName("inpu ...

Retrieve the JSON object's name and loop through its child objects

Just diving into JavaScript and web development, seeking some guidance. I'm currently working on gathering information to format and trigger another request. Here's what I have so far: JavaScript $( document ).ready(function(sb_shows) { $. ...