CSS CSS Tutorial CSS Advanced CSS Responsive Web Design(RWD) CSS Grid CSS Properties Sass Tutorial Sass Functions



scroll-padding-inline

The scroll-padding-inline property is a CSS property that is used to specify the padding area around an element's inline axis when it is scrolled. This property is used to ensure that the content of an element is not obscured by the scrollbar when it is scrolled.

The scroll-padding-inline property is used in conjunction with the overflow property, which specifies whether or not an element should have a scrollbar when its content overflows its container. When an element has a scrollbar, the scroll-padding-inline property is used to specify the amount of padding that should be added to the inline axis of the element to ensure that its content is not obscured by the scrollbar.

The scroll-padding-inline property can be used with any element that has a scrollbar, including <div>, <textarea>, and <iframe> elements. It is supported by all major web browsers, including Chrome, Firefox, Safari, and Edge.

Examples

Here are some examples of how the scroll-padding-inline property can be used:

Example 1:

In this example, we have a <div> element with a scrollbar. We want to add padding to the inline axis of the element so that its content is not obscured by the scrollbar:

  
    div {
      overflow-y: scroll;
      scroll-padding-inline: 20px;
    }
  

In this example, we have set the scroll-padding-inline property to 20px, which means that the element will have a padding of 20px on its inline axis when it is scrolled.

Example 2:

In this example, we have a <textarea> element with a scrollbar. We want to add padding to the inline axis of the element so that its content is not obscured by the scrollbar:

  
    textarea {
      overflow-y: scroll;
      scroll-padding-inline: 10px;
    }
  

In this example, we have set the scroll-padding-inline property to 10px, which means that the element will have a padding of 10px on its inline axis when it is scrolled.

Example 3:

In this example, we have an <iframe> element with a scrollbar. We want to add padding to the inline axis of the element so that its content is not obscured by the scrollbar:

  
    iframe {
      overflow-y: scroll;
      scroll-padding-inline: 15px;
    }
  

In this example, we have set the scroll-padding-inline property to 15px, which means that the element will have a padding of 15px on its inline axis when it is scrolled.

Conclusion

The scroll-padding-inline property is a useful CSS property that can be used to ensure that the content of an element is not obscured by the scrollbar when it is scrolled. It is supported by all major web browsers and can be used with any element that has a scrollbar.

References

Activity