<div class="container">
    <div class="other">
        </br>
        </br>
        </br>
        <div class="parent">
            蓝色背景是父元素
            <div class="sticky">
              我是父元素里的 Sticky 元素
            </div>
         <p class="tips">当 Sticky 元素接触到父元素底部边缘将取消粘粘</p>
        </div>
        </br>
        </br>
        </br>
        </br>
        </br>
        </br>
        </br>
        </br>
        </br>
        </br>
        </br>
        </br>
        </br>
    </div>
</div>
html, body {
    width: 100%;
    height: 100%;
    display: flex;
}

.container {
    position: relative;
    width: 333px;
    height: 50%;
    margin: auto;
    border: 1px solid #333;
    overflow: scroll;
    line-height: 44px;
}

.sticky {
    background: pink;
    position: sticky;
    top: 0;
    z-index: 1;
}

.parent {
    height: 100vh;
    background: #5872e0;
    position: relative;
}

.tips{
  position: absolute;
  bottom: 0
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.