Conceal table headers on mobile devices for better responsiveness styling

I have implemented jQuery Datatables to display a table and made it mobile responsive. However, I am facing an issue where I want to completely hide the table headers when viewing the table on a mobile device, and show them again on a normal screen.

Specifically, I have successfully hidden the headers using CSS but when I enable vertical scrolling for the table, the headers become visible on mobile view which is not desired.

Here is an example of the table code with repeated data for testing:

<table id="no-more-tables">
<thead>
    <tr>
        <th>Code</th>
        <th>Company</th>
        <th class="numeric">Price</th>
        <th class="numeric">Change</th>
        <th class="numeric">Change %</th>
        <th class="numeric">Open</th>
        <th class="numeric">High</th>
        <th class="numeric">Low</th>
        <th class="numeric">Volume</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td data-title="Code">AAC</td>

         ...

</script>

Answer №1

Since you're utilizing a datatable, the DOM is being altered. To address this in your CSS, replace #no-more-tables with #no-more-tables_wrapper. After making this adjustment, please verify that your code functions properly.

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

Creating a persistent hover effect

Utilizing primarily CSS, along with background images and adjacent selectors, I am creating a page that displays unique human-readable text information when the user hovers over horizontally stacked images. The textual information is presented in a div on ...

The sidebar remains concealed at all times within the HTML5UP prologue/Skeljs framework

Currently, I am using HTML5up Prologue with the skeljs framework at this link. In my design, I prefer to keep my menu navigation hidden on the left side, especially in the narrow view (<961pixels). The toggle div should always remain visible. For refer ...

Steps to correct color gradient on a fixed top navigation bar:

In my Bootstrap 4 project, I have a fixed navbar with a linear gradient background image. The navbar is transparent and fixed, but as I scroll down the page, the gradient disappears. Can anyone help me figure out how to keep the background image visible wh ...

Exploring effective ways to visually display percentage data in Google Charts without relying on total sample size

Hey there! I'm currently working on creating Pie Charts using the Google Charts Library to showcase browser statistics from 2004. The total sample size is unknown, but for all I know, it could be a percentage of 1.2 billion. Here's how I've ...

Steps for sending a form with jQuery's submit method1. Start

Below is the jquery code that I have written: $(document).ready(function () { $('.bar_dropdown').on('change', function() { console.log("dropdown changed") $('#bar_graph_form_id').submit(function(e ...

Modifying Label text dynamically using jQuery on Click event

My website HTML contains the following code snippet: <script src="js/jquery.flexslider.js"></script> <script src="js/jquery.rings.js"></script> The contents of jquery.rings.js are as follows: $('input[type="image"]') ...

What is the best way to incorporate a unique font with special effects on a website?

Is there a way to achieve an Outer Glow effect for a non-standard font like Titillium on a website, even if not everyone has the font installed on their computer? I'm open to using Javascript (including jQuery) and CSS3 to achieve this effect. Any sug ...

What is the best way to determine if a radio button has been chosen, and proceed to the next radio button to display varied information?

The goal is to display the <div class="resp"> below each radio button when it is selected, with different content in each <div class="resp">. The previously selected <div class="resp"> should be hidden when a new radio button is chosen. O ...

Difficulty detecting changes in Bootstrap modal forms

I am experiencing an issue with a form in a Bootstrap modal that I am using to edit record values. Despite making changes to the fields and saving the modal, the jQuery .serialize() function is still capturing the original values displayed in the modal. I ...

Encounters a fault while processing the php output

Displaying an error in the query The browser is showing the correct answer. $.ajax({ type: "POST", url: url, async: true, contentType: " charset=utf-8", dataType: "XMLHttpRequest", success: func ...

Performing multiple AJAX requests in parallel using jQuery to communicate with an Express server

I have been using the following code to send 10 ajax requests to a server and receive a response from Express: for(i=0;i<3;i++){ $.ajax({ url: "http://myserver.ca:3000/json", dataType: "jsonp", data: { reqType ...

Introduce new material at the start of each line, akin to what ::before accomplishes for the initial line

I am currently working on customizing the appearance of my <code>/<pre> tags while ensuring that users can still easily highlight and copy the code. The method I had in mind (shown below) only applies to the first line and doesn't repeat ...

Transmit responses from PHP script

I am in the process of creating a signup form where, upon clicking the submit button, all form data is sent to a PHP file for validation. My goal is to display an error message next to each input field if there are multiple errors. How can I achieve this ...

What is the process for customizing styles within the administrative area of a Wordpress website, such as modifying the shade of the admin toolbar?

Can someone provide guidance on changing the color of a specific dashicon in the WordPress admin toolbar? I've tried adjusting the color using the browser inspector, but I can't seem to get it to work when I add the code to my stylesheet. #admin ...

Can you provide tips on leveraging CSS as a prop for a Vuetify v-tab component?

Currently, I am in the process of updating my website to simplify color palette swapping. We are still experimenting with different colors that work well together. Our stack includes Vue and Vuetify, with SCSS generating our primary CSS file. Most of our c ...

Creating interactive panorama hotspots with THREE.js SphereGeometry and DOMElements

After creating a WebGL 3D Panorama application using a SphereGeometry, PerspectiveCamera, and CanvasTexture, I am now trying to enhance the scene by adding "HotSpots" over specific areas of the SphereGeometry. However, I am facing difficulty in updating th ...

Page Built with Bootstrap Showing Excessive White Space Below and Footer Misaligned

Looking for some assistance with a webpage I've been working on. Here is the page in question: I used the official static navbar example from Bootstrap as inspiration: https://getbootstrap.com/examples/navbar-static-top/ As well as the official stic ...

Dynamically adjusting CSS Max-Height according to scroll position

Is there a CSS only technique to achieve the following scenario: An element is positioned absolutely at x,y coordinates on the screen. The document includes a vertical scrollbar depending on its content. Can the height of the element be adjusted based on ...

How to Align a Footer to the Bottom of the Page using Bootstrap 5

My issue arises when using a dark background footer, as some pages lack enough content to fill the entire browser's viewport. Consequently, an unsightly white band appears below it. How can I ensure the footer reaches the bottom of the viewport on pa ...

Is it possible to refresh front-end data without reloading the page?

I am looking to automatically update data on the front-end when there are changes in the database, without requiring a page refresh. For example, if a div displays the number 541236 and the corresponding value in the database is also 541236, and then the ...