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
ἔρως
ἔρως2mo 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
DoksuriOP2mo ago
i didn't understand what you meant 🤔
ἔρως
ἔρως2mo ago
when you put borders on the table, the borders collapse into a single border instead of being 2 borders completely separated
Doksuri
DoksuriOP2mo ago
ah ok
ἔρως
ἔρως2mo 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
DoksuriOP2mo ago
adding the position sticky doens't change anything... did i miss something ?
ἔρως
ἔρως2mo ago
yes you need to have top without top, it doesnt work
Doksuri
DoksuriOP2mo ago
my bad... wrote too fast : position sticky + top doesn't change anything...
ἔρως
ἔρως2mo ago
also, the table has to scroll off of the screen
Doksuri
DoksuriOP2mo ago
adding sticky + top only "pushes" the table down
ἔρως
ἔρως2mo 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
DoksuriOP2mo ago
aaaah i got it... i didn't touch the table, but added the sicky bottom to the button solves the problem !
Doksuri
DoksuriOP2mo ago
Edit fiddle - JSFiddle - Code Playground
JSFiddle - Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle.
ἔρως
ἔρως2mo ago
it does, but ... it's not the best
Doksuri
DoksuriOP2mo ago
this is what i wanted \o/
ἔρως
ἔρως2mo ago
but doesnt always work
No description
ἔρως
ἔρως2mo ago
but, if you are happy with it, you can keep how it is it's not wrong
Doksuri
DoksuriOP2mo 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
ἔρως
ἔρως2mo 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
DoksuriOP2mo ago
👍 ok thanks for the help
ἔρως
ἔρως2mo ago
you're welcome
Want results from more Discord servers?
Add your server