<div class="container">
  <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</p>
</div>
body {
  height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* Keyframes animation to detect scroll status */
@keyframes detectScroll {
  from,
  to {
    --scroll-status: /* A custom variable to check the scroll status */
  }
}

.container {
  resize: vertical;
  overflow: auto;
  width: 300px;
  height: 150px;
  padding: 12px;
  margin-top: 12px;

  /* Apply scroll animation */
  animation: detectScroll linear;
  animation-timeline: scroll(self); /* Bind the animation to the container's scroll behavior */

  /* Define background color based on scroll status */
  --bg-scrollable: var(--scroll-status) #008000; /* Green if scrollable */
  --bg-scrollable-hide: #FF0000; /* Red if not scrollable */
  background-color: var(--bg-scrollable, var(--bg-scrollable-hide)); /* Set the background color */
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.