CSS scroll-padding-left Property

The scroll-padding-left property is used to set all the padding to the left of an scroll container or element at once. The value specified for the scroll-padding-left determines how much of the page that is primarily outside the snapsort should remain visible.

Syntax:

scroll-padding-left:length_values

Or

scroll-padding-left:keyword_values

Or

scroll-padding-left:Global_Values

Property values: This property accepts three properties mentioned above and described below.

  • length_values: This property refers to the values defined with length units. Ex: px, em, vh, % etc.
  • keyword_values: This property refers to the keyword_values defined with units like auto. Generally, this will be set to 0px by default but it can be a non-zero value as well, if the non-zero value is more appropriate.
  • Global_Values: This property refers to the global values like inherit, initial, unset, etc.

Example: Below example illustrates the scroll-padding-left property.

HTML




<!DOCTYPE html>
<html>
 
<head>
    <style>
        .geek {
            width: 275px;
            height: 300px;
            border: 2px solid red;
            scroll-snap-align: none start;
        }
 
        .w3wiki {
            width: 300px;
            height: 300px;
            border: 2px solid green;
            text-align: center;
            overflow-x: auto;
            overflow-y: hidden;
            white-space: nowrap;
            scroll-snap-type: x mandatory;
        }
    </style>
</head>
 
<body>
    <div class="w3wiki" style=
            "scroll-padding-left: 80px;">
        <img src=
"https://media.w3wiki.net/wp-content/uploads/20200723131449/img5.jpeg"
            class="geek">
        <img src=
"https://media.w3wiki.net/wp-content/uploads/20200723131450/img6-300x82.png"
            class="geek">
        <img src=
"https://media.w3wiki.net/wp-content/uploads/20200723131452/img4-300x167.png"
            class="geek">
        <img src=
"https://media.w3wiki.net/wp-content/uploads/20200723131450/img6-300x82.png"
            class="geek">
        <img src=
"https://media.w3wiki.net/wp-content/uploads/20200723131449/img5.jpeg"
            class="geek">
    </div>
</body>
 
</html>


Output:

Supported Browsers:

  • Chrome 69 and above
  • Firefox 68 and above
  • Opera 56 and above
  • Edge 79 and above
  • Safari 14.1 and above