I am trying to make sticky footer inside of a horizontally scrolling element. I want that sticky footer to be aligned to the bottom, have auto height based on it's content and be as wide as scroll parent (in this example 200px), so when I scroll to the right, footer is on the same place and it's content is horizontally centered (content should be some element, not only a simple text). I would appreciate help.
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>
Thanks a lot.
