I'm trying to make this card with a sticky top and sticky bottom since they show some info and inputs that I would like to be always shown. The problem is that after scrolling some of the content inside, the top goes away and I don't want that.
I found out that the problem goes away after removing the card-footer or styling the card height on auto. The thing is that where I want to position if the screen size is large enough needs a specific height. Also can't remove the footer because It has content.
I've tried moving the sticky's outside the card-body but then on mobile they would be lost in the scrolled away kingdom...
The answers I've found on other questions weren't very helpful since many are for sticky footers and aren't trying to put the sticky inside a bootstrap card
.sticky-top {
position: -webkit-sticky;
position: sticky;
top: 0;
height: 30px;
background: red
}
.sticky-bottom {
position: -webkit-sticky;
position: sticky;
bottom: 0;
height: 30px;
background: lightblue;
}
.the-problem {
height: 30px
}
.content {
height: 600px;
background: gray
}
#thing {
height: 200px;
width: 300px;
overflow: auto;
}
#thing {
width: 300px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />
<form id="thing" class="card mt-3">
<div class="card-header">An unimportant title</div>
<div class="card-body p-0" style="overflow: initial">
<div class="sticky-top">
sticky-top
</div>
<div class="content"> Some content </div>
<div class="sticky-bottom">
sticky-bottom
</div>
<div class="card-footer the-problem px-3">
</div>
</div>
</form>
<form id="thing2" class="card mt-3">
<div class="card-header">An unimportant title</div>
<div class="card-body p-0" style="overflow: initial">
<div class="sticky-top">
sticky-top
</div>
<div class="content"> Some content </div>
<div class="sticky-bottom">
sticky-bottom
</div>
<div class="card-footer the-problem px-3">
</div>
</div>
</form>