What is the best way to add a scrollbar above a table?

My table is wide and doesn't fully fit on normal monitors. Is there a way to add a scroll bar above the table or the container div? Check out the scroll bar used in the users table of Discourse here.

HTML

<div id="table_div">
    <table id="myTable">
       //content goes here           
    </table>
</div>

CSS

#table_div {
overflow-x: auto;
float: left;
width: 90%;
margin-left: 5%;
}

#myTable {
height: auto;
background-color: white;
border-collapse: collapse;
text-align: center;
border: 1px solid #ddd;
font-size: 16px;
width: 1305px;
}

Answer №1

To achieve a scrollbar appearing on top of the table, you can utilize CSS with the transform: rotateX() property applied to #table_div.

#table_div {
  overflow-x: auto;
  float: left;
  width: 90%;
  margin-left: 5%;
  transform: rotateX(180deg);
}

#myTable td {
  height: auto;
  background-color: white;
  border-collapse: collapse;
  text-align: center;
  border: 1px solid #ddd;
  font-size: 16px;
  width: 1305px;
  transform: rotateX(180deg);
}
<div id="table_div">
  <table id="myTable">
    <tr>
      <td>Content</td>
      <td>Content</td>
      <td>Content</td>
      <td>Content</td>
      <td>Content</td>
      <td>Content</td>
      <td>Content</td>
      <td>Content</td>
      <td>Content</td>
      <td>Content</td>
      <td>Content</td>
      <td>Content</td>
      <td>Content</td>
      <td>Content</td>
      <td>Content</td>
      <td>Content</td>
    </tr>
  </table>
</div>

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

Authenticate the user by comparing the entered username and password with the database records. If they match, proceed to redirect the user to their profile page. Otherwise, log

Attempting to complete this assignment which involves a user entering their username and password. If the information matches what is stored in the database, the user should be redirected to their profile page where a personalized greeting message is displ ...

What is the best approach for extracting JSON data (using jQuery) from Google Geocoding services?

Obtaining the city name using latitude and longitude is my current challenge. Google Geocoding offers a helpful solution known as "Reverse geocoding". According to the documentation, a GET request needs to be made to the following link: http://maps.googl ...

Unshrinkable item causing multiple lines text-overflow in a flexbox layout

My goal is to achieve the following design: https://i.stack.imgur.com/YLUtN.png Currently, I have attempted the following approach (although it doesn't fully meet my requirements): .parent { max-height: 40px; display: flex; flex-wrap: wrap; ...

Activating a inaccessible element

Attempting to enable a disabled element upon clicking a P element, the following code snippet demonstrates storing a value from one textbox into another. The appended div contains a subsequent textbox which will be disabled. On mouseover of the div, option ...

What is the best way to ensure that the larger child divs always fit perfectly within the parent div?

Creating a Responsive Layout <div class="container"> <div class="box1"></div> <div class="box2"></div> <div class="box3"></div> </div> CSS Styling .box1, .box2, .box3{ display: block; f ...

Is the MDL drawer not reaching the full height of the page?

I am currently utilizing Material Design Lite to incorporate a fixed header and drawer into my Ruby on Rails application. In the following video, you can observe that when I switch to another page, the drawer menu on the left side of the page fails to fill ...

Tips for storing HTML form data in a local JSON file without the need for PHP or Node.js dependencies

I'm interested in saving any information panel in an HTML file to a local JSON file. For example, if there are blocks like this: <div class="panel"> <div> <input type="text" name="producttype" id=&q ...

Issue with repeated items in Flatlist

Whenever I display my flatlist, it appears to be duplicating the items within it (the feedCache has only one index but the data for this index is rendered twice). Below is the code snippet for the flatlist: const FeedBody = React.memo(() => { return ...

State variable in Redux is not defined

While there have been numerous similar inquiries on this platform, I haven't been able to find a solution to my particular issue. Below is the React component in question: class MyTransitPage extends Component { componentDidMount() { this.pro ...

What is the most effective method to exhibit every element within a content wrapper at a specific interval of time?

I am looking for a way to display each div within the content-wrapper after a specific time interval. Currently, I am using individual classes like el1, el2, el3, ... to accomplish this task. However, when dealing with content-wrappers containing multipl ...

Issues with alignment within Bootstrap grid system

I have three unique "cards" that I want to display horizontally and center on the page without using the bootstrap card class. Currently, I am attempting to assign each of them a width of .col-lg-4 within an outer div set to full width. However, they are s ...

Executing Cross-Origin Resource Sharing in Angular and Node

I have implemented a frontend using Node.js and AngularJS, with the backend running on Jetty exposing REST services. I need to send a REST request from the frontend (Angular) to the backend. When I pass the complete URL to $http.get it works fine. However, ...

Encountering a problem when attempting to send an HTML email through PHP

Trying to use PHP to send email within an HTML code snippet. Here's the code I've written: <?php if($_SERVER['REQUEST_METHOD'] == 'POST') { if ( mail ('<a href="/cdn-cgi/l/email-protection" class="_ ...

Transmit information from a website to a server located nearby

Creating a home automation hub is my current project -- utilizing a Raspberry Pi as the foundation to display weather updates, control lighting, and more. This setup is connected to a website through a shared MongoDB database, with both systems running Nod ...

PHP MySQL data not getting saved when button is clicked and $.ajax function is executed

Having an issue with the code below regarding saving form data: "fsField" is the class assigned to all form elements. The autosave() function is triggered when a user moves away from a field by clicking out, except when they click the 'save_secL&apos ...

Temporarily withhold the execution of useEffect until useSelector successfully fetches data from the Redux store within a React

I have a functional React component called Tasks_1. Initially, I retrieve the userId from the Redux store, which is working successfully. After obtaining the userId from the Redux store, I want to use it in a useEffect hook to fetch data from the backend. ...

Issue with retrieving date from MySQL column being a day behind in JavaScript (Node.js)

I currently have a Node.js server up and running as the API server for a service that I am developing for a company. The dates stored in the MySQL server that it connects to are related to event start times. Insertion of these dates is flawless, and when ...

A CSS rule to display a nested list on the left-hand side

I created a menu that you can view here. When hovering over "tanfa demo example," the sublist appears on the right side. The issue I'm facing is that my menu is positioned all the way to the right, which means the sublist also appears on the extreme ...

"An issue with the colyseus server has been detected within the JavaScript code

I have written some code but it seems to be causing errors. const colyseus = require("colyseus"); const http = require("http"); const express = require("express"); const port = process.env.port || 3000; const app = express(); ...

Retrieving data from Firestore yields an empty result

Having trouble reading from Firestore within a function, even though writes are working fine. Despite following examples on the given link, the query below and its variations result in an empty promise: module.exports.customerByPhone = phone => { r ...