I am working on creating a sticky footer within a horizontally scrolling element. I want the sticky footer to be positioned at the bottom, adjust its height based on the content inside it, and match the width of the scrollable parent (in this case 200px). The goal is for the footer to stay in place when scrolling horizontally and have its content centered horizontally (the content being more than just plain text). Any help would be greatly appreciated.
Desired outcome: https://i.sstatic.net/zYyVx.png
This is my current code:
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
}
.example {
width: 200px;
overflow-x: auto;
}
.container {
position: relative;
display: flex;
width: 400px;
height: 100px;
background-color: moccasin;
}
.footer {
position: sticky;
bottom: 0;
background-color: palegreen;
justify-self: center;
}
<div class="example">
<div class="container">
<div class="footer">
Footer
</div>
</div>
</div>
Thank you so much.