.container
  .container__inner overflow-x:clip
    .stickyBox
      span position:sticky
View Compiled
body {
  background: #000;
  padding: 0;
}

.container {
  overflow: visible scroll;
  max-width: 300px;
  height: 90vh;
  margin: auto;
  background: #fff;
}

.container__inner {
  overflow-x: clip;
  height: 300vh;
}

.stickyBox {
  position: sticky;
  top: 0;
  width: 100px;
  height: 100px;
  margin: 100px auto 0;
  background: skyblue;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.