Learn CSS daily

Generate Your Own Playground

Type any CSS property and get a live, editable playground instantly.

scroll-padding-inline
.container {
  width: 300px;
  overflow-x: auto;
  border: 2px solid #333;
  scroll-padding-inline: 20px;
}

.scroll-area {
  display: flex;
}

.item {
  min-width: 100px;
  height: 100px;
  margin-right: 10px;
  background-color: lightblue;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #007BFF;
  font-size: 20px;
}

The 'scroll-padding-inline' property in CSS defines the padding area on the inline axis (left and right) when scrolling to an element. This property is particularly useful in creating a comfortable visual experience by ensuring that the target element is not flush against the edges of the viewport when scrolled into view, especially in horizontal scrolling contexts.

scroll-padding-block-start
.container {
  height: 200vh; /* Make the container tall enough to scroll */
  padding: 20px;
  scroll-padding-block-start: 100px; /* Set padding for scroll position */
}

h1 {
  margin-top: 100px; /* Space between sections */
}

nav {
  position: fixed;
  top: 10px;
  background: rgba(255, 255, 255, 0.8);
  padding: 10px;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

p {
  margin: 20px 0;
}

The 'scroll-padding-block-start' CSS property defines the padding area on the block start side of a scroll container. This padding area is used to adjust the scroll position when navigating to an anchor link within the container, ensuring that the target element is not obscured by fixed headers or other elements. It enhances user experience by providing a more visually appealing scroll effect.

scroll-padding-block-end
.scroll-container {
  height: 200px;
  overflow-y: scroll;
  border: 2px solid #333;
  scroll-padding-block-end: 30px;
}

.scroll-item {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f0f0f0;
  border: 1px solid #ccc;
  margin: 5px;
}

button {
  margin-top: 20px;
  padding: 10px;
  font-size: 16px;
}

The 'scroll-padding-block-end' CSS property defines the padding area on the end edge of a scrolling container, which affects the alignment of scrollable content when using scroll-related methods. This property is particularly useful for enhancing the user experience by ensuring that elements are not cut off when scrolling to them, especially in vertical layouts.

scroll-padding-block
.scroll-container {
  height: 200px;
  overflow-y: scroll;
  scroll-padding-block: 50px;
  border: 2px solid #333;
}
.scroll-item {
  height: 100px;
  background-color: #f0f0f0;
  margin: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ccc;
}
button {
  margin-top: 20px;
  padding: 10px 20px;
  font-size: 16px;
}

The 'scroll-padding-block' property in CSS defines the padding area on the block start and block end of a scroll container. It is particularly useful for controlling the scroll position when an element is focused or navigated to, ensuring that it appears within a specified padding area, enhancing the user experience in scrollable sections.

scroll-padding
.scroll-container {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 50px;
  width: 100%;
  height: 200px;
  border: 2px solid #ccc;
}

.section {
  flex: none;
  width: 300px;
  height: 100%;
  scroll-snap-align: start;
  border: 1px solid #333;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  background-color: #f0f0f0;
  margin-right: 10px;
}

The 'scroll-padding' property in CSS defines the padding area around the scroll container for scroll snap points. It helps control the position of the snap points when scrolling, ensuring that the content is aligned properly within the viewport. This property is particularly useful for creating smooth scrolling experiences in applications with multiple sections or items.