is it possible to set the scroll on a table and not its container ?

hi all, https://jsfiddle.net/n0x8e5L6/ in this example, i have a container with a table & a button. my button is hidden since my table is too long. is it possible to set a scroll on the table so my button is always visible ? i don't want to add an other container just for the table...
Edit fiddle - JSFiddle - Code Playground
JSFiddle - Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle.
21 Replies
ἔρως
ἔρως3mo ago
why dont you try setting thead { position: sticky; top: <height of the header>; } on that table? this way, the <thead> is stuck at the top of the page, even when the table is scrolled off screen otherwise, use grid to make the middle section scrollable this has the huge disadvantage of obliterating border collapsing
Doksuri
DoksuriOP3mo ago
i didn't understand what you meant 🤔
ἔρως
ἔρως3mo ago
when you put borders on the table, the borders collapse into a single border instead of being 2 borders completely separated
Doksuri
DoksuriOP3mo ago
ah ok
ἔρως
ἔρως3mo ago
for example: td { border: 1px solid red; } without border collapse, you would see 1px on the left and right side, then 2px between each cell that looks fugly af but honestly, the sticky option might be the best if you have a <tfooter> you can put it at the bottom
Doksuri
DoksuriOP3mo ago
adding the position sticky doens't change anything... did i miss something ?
ἔρως
ἔρως3mo ago
yes you need to have top without top, it doesnt work
Doksuri
DoksuriOP3mo ago
my bad... wrote too fast : position sticky + top doesn't change anything...
ἔρως
ἔρως3mo ago
also, the table has to scroll off of the screen
Doksuri
DoksuriOP3mo ago
adding sticky + top only "pushes" the table down
ἔρως
ἔρως3mo ago
sorta but you can put the button on the thead and this way, its always visible or you can put the button on a tfooter and it will always be visible
Doksuri
DoksuriOP3mo ago
aaaah i got it... i didn't touch the table, but added the sicky bottom to the button solves the problem !
Doksuri
DoksuriOP3mo ago
Edit fiddle - JSFiddle - Code Playground
JSFiddle - Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle.
ἔρως
ἔρως3mo ago
it does, but ... it's not the best
Doksuri
DoksuriOP3mo ago
this is what i wanted \o/
ἔρως
ἔρως3mo ago
but doesnt always work
No description
ἔρως
ἔρως3mo ago
but, if you are happy with it, you can keep how it is it's not wrong
Doksuri
DoksuriOP3mo ago
it is for a desktop app. i don't need to test littles screens i even tested 150px, but in reality, it's bigger
ἔρως
ἔρως3mo ago
150px height is probably enough but hey, if you are happy with how it is, keep it like that it isnt wrong or bad
Doksuri
DoksuriOP3mo ago
👍 ok thanks for the help
ἔρως
ἔρως3mo ago
you're welcome
Want results from more Discord servers?
Add your server