Skip to content

[css-conditional-5] scroll-state(stuck) will remain applying its @container ruleset for elements has left viewport #12302

Open
@n0099

Description

@n0099

https://jsfiddle.net/ebkafjtp/18/

<div class="container">
  <div class="sticky"></div>
  <div class="sticky"></div>
  <div class="sticky"></div>
  <div class="sticky"></div>
  <div class="sticky"></div>
</div>
.sticky {
  container-type: scroll-state;
  position: sticky;
  top: 0;
  height: 30vh;
  margin-block: 2rem;
  background: gray;
}
.sticky:nth-child(even) {
  background: darkgray;
}

@container scroll-state(stuck: block-start) {
  *::before {
    content: 'block-start';
  }
}
@container scroll-state(stuck: none) {
  *::before {
    content: 'none';
  }
}

When scrolling the viewport to the end, any .sticky whose getBoundingClientRect().bottom is negative will still have their ::before { content: 'block-start'; } style that defined in the <block-contents> of @container.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions