Background color of a scrolling overflow-x panel-primary in Bootstrap

Seeking help with a CSS issue related to a Bootstrap panel. When the overflow-x property is activated, the blue background color of the panel-heading transitions to white instead of staying blue. Any suggestions on how to maintain the blue color while keeping overflow-x active?

CSS:

  .panel-primary {
    max-width: 100%;
    overflow-x:scroll;
    white-space: nowrap;
  }

HTML:

<div class="row form-group">
<div class="panel panel-primary">
<div id="hpanel" class="panel-heading">Heading</div>
<div class="panel-body">
  <table id="example" class="display" cellspacing="0" width="100%">
    <thead>
      <tr>
        <th>Col1</th>
        <th>Col2</th>
        <th>Col3</th>
        <th>Col4</th>
        <th>Col5</th>
        <th>Col6</th>
        <th>Col7</th>
        <th>Col8</th>
     </tr>
   </thead>
   <tbody>
     <tr>
       <td>some data</td>
       <td>some data</td>
       <td>some data</td>
       <td>some data</td>
       <td>some data</td>
       <td>some data</td>
       <td>some data</td>
       <td>some data</td>

     </tr>
    </tbody>
  </table>
</div>
</div> 
</div>

JS:

$(document).ready(function() {
var table = $('#example').DataTable( {

    } );
} );

Check out the jsfiddle for reference

Thank you

Answer №1

After experimenting with different solutions, I found the answer to my own question. By wrapping a div around the table element, I was able to achieve the desired outcome.

<div class="table-responsive">
   <table>
   .....
   </table>
</div>

This approach makes the table data responsive, addressing the color issue and providing a more effective solution overall. I have now updated the code in my original fiddle with this new implementation.

Many thanks,

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

When hovering over a single list item, only the top border will be displayed without affecting the

Check out the live link provided below: I am attempting to add a border and later an arrow in the middle on hover in the menu. However, the current code places a border over the entire menu, with individual list items on top of that. #menu ul li { margin ...

Toggle between different icons with Bootstrap 4

Can someone help me with changing the bootstrap 4 navbar-toggler-icon appearance when it's open or closed using CSS? I have been trying to figure it out but so far, I haven't found a straightforward solution. .map-controls-mobile .navbar-toggler ...

What is the best way to ensure a sidebar's height matches the height of the content in a two-column table using div elements?

Just finished setting up a 2-column layout with a content div, sidebar div, header, and footer. You can check out the live example here. Any tips on how to make the sidebar's height match the content height (like a 2-column table)? Utilizing jquery ...

Adjust SVG size to fit parent container/division

I am trying to make the SVG completely fill the containing TD. I don't care about preserving the proportions of the SVG. Instead, I want the height of the SVG to be the same as its width when the height should be larger than the width. There is paddin ...

Can Jquery use .hover to add a class or Child:hover to impact its parent element?

I have been searching for a solution tailored to my specific needs, and I am encountering difficulties in getting a seemingly simple jQuery code to function as expected. Here is the link to my basic fiddle: http://jsfiddle.net/LBHxc/ (I apologize for the ...

The alignment of the image background is malfunctioning on the iPad 3 device

Hey there, I need some assistance resolving an issue with a header background image on iPad3. The problem is that the image is not displaying correctly on iPad3 browsers, even though it works fine on desktop browsers. Below you can find my CSS and HTML cod ...

The fixed div is always positioned in the top corner

My webpage has a 'Book Now' button that remains at the top of the viewport with a 10px gap. However, due to the parent element having a height of 100%, the button scrolls out of view once the viewport surpasses that height. To see an example, cli ...

Determine the height of an element in JavaScript or jQuery by using the CSS property height: 0;

I'm facing a challenge in determining the actual height of an element, which currently has a CSS height property set to: height: 0; When I check the console, it shows a height of 0, but I'm looking to find the real height of the element. I als ...

change content of attached document when clicked

On all of my pages, I have included my header.php file. However, I am facing an issue with destroying sessions. Even though I have a logout.php page where I attempt to destroy the session, it is not happening as expected. The session remains registered wit ...

Sluggish Bootstrap Carousel Requires Mouseover or Click to Start Sliding

Having Trouble with Bootstrap Carousel Sliding: I've been trying to solve this issue for a while now, but nothing seems to be working. I know this might be a common question, but I really need to fix this problem quickly and none of the suggested solu ...

change visibility:hidden to visible in a css class using JavaScript

I've put together a list of Game of Thrones characters who might meet their demise (no spoilers included). However, I'm struggling with removing a CSS class as part of my task. Simply deleting the CSS is not the solution I am looking for. I' ...

Establishing updated file path for resources in JavaScript based on environment

I'm currently facing an issue with my external Javascript file that uses the getScript() function to execute another JS file. Both files are located on static.mydomain.com, as I am trying to set up a Content Delivery Network (CDN) for the first time. ...

Creating a dynamic animation effect on a div with a changing number of child elements

Currently, I am utilizing the nganimate library and have implemented an animation that affects the max-height property of a div. Here is a snippet of my code: CSS .sublist.ng-hide { max-height: 0; } .sublist { max-height: 1300px; overflow: hidden; ...

Retrieving all buttons from a webpage and removing those with a specific background-image using JavaScript

Hey everyone, I'm still learning about javascript and other web development languages. My current task is to locate all the buttons on a webpage and remove the ones that have a specific background image. I know about using getElementsByTagName but n ...

React drag and drop feature now comes with autoscroll functionality, making

I am encountering an issue with my nested list Items that are draggable and droppable. When I reach the bottom of the page, I want it to automatically scroll down. Take a look at the screenshot below: https://i.sstatic.net/ADI2f.png As shown in the image ...

The functionality of the anchor tag is not supported by the Safari browser on iPhone devices

Having some trouble with a named anchor tag in the iPhone Safari browser. It's functioning properly in desktop browsers, including Safari, but not working on mobile Safari. Odd! For instance, my URL appears as: http://www.example.com/my-example-arti ...

Ensuring consistency in aligning float elements

I've been struggling to create a concept design for my internship project. I aim to have a page with six clickable elements (images). When one is clicked, the others should disappear and the active one moves to the top. I managed to achieve this using ...

The Bootstrap Navbar is causing the navigation bar to span across two lines

I'm having an issue with my navbar taking up two lines on desktop resolution, but fitting perfectly on mobile. I've spent hours going through the code with no success. Any help would be greatly appreciated. The HTML code is provided below. <! ...

updating the background image in CSS after uploading a photo using Ajax

Whenever I click on an element, it triggers an input dialog that allows me to upload a photo. The server then responds with a JSON OBJECT containing 4 items: NAME, TYPE, HEIGHT, WIDTH. My goal is to refresh the element's background with the newly upl ...

Entering text into the input field with the string "Foo"<[email protected]> is not functioning correctly

The text in my input is initially filled with this string "foo foo"<<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4f2920200f29202061263b">[email protected]</a>>. However, after an insert, the string now l ...