Apply position: sticky to child of a div

后端 未结 4 1850
北荒
北荒 2020-12-16 12:48

Position: sticky doesn\'t seem to work for me when I apply it to a child of a div. How to solve?

HTML:

Lorem Ipsum
4条回答
  •  甜味超标
    2020-12-16 13:43

    Put everything inside your this-parent-div-is-necessary container.

    .div-sticky-class {
      color: red;
      position: sticky;
      position: -webkit-sticky;
      top: 0;
    }
    Lorem Ipsum
    Test
    Lorem Ipsum



































































































































提交回复
热议问题