I have searched and analyzed the answer on this subject, but it is not really clear to me what is the optimal solution to solve this problem.
I was doing tests placing my predecessors display: initial
and it works perfectly, however what happens when you have a display: flex
whole thing breaks.
I have created a link to codesandbox for your analysis and how this can be easily fixed (if possible).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Static Template</title>
</head>
<body>
<div class="container">
<div class="app-content">
<div class="another-container">
<div class="card-sticky">
Sticky card
</div>
</div>
</div>
</div>
</body>
</html>
<style>
.container {
height: 200vh;
}
.card-sticky {
position: sticky;
top: 0;
}
</style>