Is it possible to fix the rightmost column in a scrollable HTML/CSS table with Angular when using overflow-x?

Is there a way to lock the right-most column in an HTML CSS Angular table that is scrollable using overflow-x? I have attempted using the sticky property and also creating two tables side by side, but neither method has successfully achieved the desired outcome. Would overlaying two tables on top of each other be the correct approach?

Answer №1

position: sticky is functioning well on both Chrome and Firefox:

div {
  width: 100%;
  overflow: hidden;
  overflow-x: scroll;
}

table, th, td {
  border: 1px solid black;
  background-color: white;
}

table {
  width: 1000px;
}

.sticky-col {
  width: 40px;
  position: sticky;
  right: 0;
}
<div>
<table>
  <tr><th>1</th><th>2</th><th class="sticky-col">3</th></tr>
  <tr><td>1,1</td><td>1,2</td><td class="sticky-col">1,3</td></tr>
  <tr><td>2,1</td><td>2,2</td><td class="sticky-col">2,3</td></tr>
  <tr><td>3,1</td><td>3,2</td><td class="sticky-col">3,3</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

Generating visual content from an application programming interface

<div class="row box"> <div class="col-md-4 pic"></div> <div id="temperature" class="col-md-4 change make_blue bigger_text"> Placeholder </div> <div class="col-md-4"> <button id="getChange" class="make_ ...

Retrieve JSON data within an HTML element, where the element is sourced from an AJAX GET response

What is the best way to extract JSON data from the response below? $.get('http://localhost:8000/json', function(response) { alert(response); }); The response is as follows: <div id="dom-target" style="display: none;"> {"logo":"log ...

What steps can I take to ensure my menu is responsive in the right way

What is the best way to create a responsive menu that displays properly on cell phones? On computers, it looks like this: [insert image description here][2] I'm having trouble with my menu not disappearing when I select an option, instead it just goe ...

Box-free calendar dash component

Encountering an issue within my application dashboard, here's a direct screenshot: https://i.stack.imgur.com/sEMrM.png The problem is that the Calendar days are extending beyond the borders of the calendar box. To implement this, I simply utilized ...

Creating a Simple Single Page Application with Node.js and Express

I am currently facing a challenge in getting my tiny SPA app to function properly. Within my app folder, the structure looks like this: /about.html /index.html /index.js index.js: const express = require('express'); const app = express(); co ...

Using Three.js, the loaded mesh's position displays variation compared to a basic geometry mesh

I've been attempting to position a mesh at a specific location, but I'm facing difficulties in achieving the exact placement I desire. While I can successfully position a simple sphere so that its left-most point aligns with the left border of my ...

Can you explain the distinction between cdnjs and npm?

Can you explain the distinctions between cdnjs and npm? Is npm considered a type of CDN (content delivery network)? ...

When using JSON.Stringify in a React App, it only displays the first item and the length of the object instead of all the other items

Working on a React App, I encountered an issue while trying to convert an array to JSON and send it to the server. My approach was like this: console.log(JSON.stringify(mainArray)) I anticipated seeing output like this during testing: "breakfast": { ...

Storing user input from HTML forms in a MySQL database table with PDO

Currently, I am in the process of developing a webpage that will contain multiple forms for users to fill out and submit. Once submitted, PHP will be responsible for executing a query to insert all the data into the table within their respective fields. I ...

Creating an autofocus feature using Angular 7 upon clicking a button

Within a table in my application, I have text boxes that are initially disabled and then enabled after clicking an edit button. Everything is working smoothly so far, but I am trying to set the autofocus to the first textbox of the first row when the edi ...

Obtaining a return value from a function in Angular

After just starting to work with Angular, I am attempting to extract a value from a button displayed in the HTML using a function. `<button class="btn" id="btn-gold" (click)="value(9)" name="mybutton" value="9">` 9 I have also inclu ...

What could be causing the issue with dayjs dynamic importing in TypeScript?

Currently, I am developing a web screen within a .NET application and facing an issue with sending datetime preferences from the system to the web screen using CefSharp settings. AcceptLanguageList = CultureInfo.CurrentUICulture.Name In my TypeScript code ...

Transforming the appearance of the menu element in Vue using transitions

In my Vue app, I have this SCSS code that I'm using to create a smooth transition effect from the left for a menu when the isVisible property is set to true. However, I am encountering an issue where the transition defined does not apply and the menu ...

Adjust background image size to fit the dimensions of the foreground content

I have a div where an image and content are inside. I am trying to make the background image adjust its size based on the content within it, rather than showing the full image size with empty space. My current styling uses flexbox: .section { height: ...

Fetching data in React hooks can be done without relying on useEffect or setTimeout. Instead, you can utilize other methods to achieve

INFORMATION* const Information = (props) { const { fetchNewest, retrieveAllData } = useRoom(); const [ data, setData ] = useState([]); const [ status, setStatus ] = useState([]); useEffect(() => { const fetchData = async () ...

To retrieve data from an AJAX response, you will receive an array in the form of a string

After requesting a list of posts submitted by users from my server, the response I received was a string containing an array of stdClass objects. If it had been an actual array, that would not have been an issue. However, it arrives as a string in the foll ...

md-list-item containing md-radio-button

Trying to tackle this particular issue: https://github.com/angular/material2/issues/1518 I want the ability to click anywhere on the line of my md-item and have it trigger the radio-button action. settings.component.html : <md-radio-group [(ngModel) ...

Could an element's loading be postponed on the initial page a user lands on?

One of my clients has requested a live chat system to be added to their website. I am fully capable of implementing it, and it is included through a script tag. Additionally, they have asked for a slight delay before the chat system loads in. My initial t ...

Function for accessing multidimensional arrays in PHP

I am currently working on a function to multiply two numeric multidimensional arrays. I have implemented three loops to iterate over the corresponding rows and columns. However, something seems to be going wrong. For some reason, when I comment out the fu ...

Modify the href value by matching it with the parent div attribute

I am working on an HTML project <div class="1" style="" title="NeedthisText TextIDontneed"> <div class="2> <div class="3"> <a target="_blank" href="/NeedToChange/DispForm.aspx?ID=1"></a> </div> </div> &l ...