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