Open In App

How to Change the Position of Scrollbar using CSS?

Last Updated : 20 Jun, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Changing the position of the scrollbar using CSS can significantly enhance the user interface and user experience of your website. By default, scrollbars appear on the right side of the element, but with modern CSS techniques, you can customize their placement and appearance — especially for web apps and RTL (Right-to-Left) languages. Approximately 90% of developers rarely alter the scrollbar's position, yet 10% utilize such styling to improve accessibility or visual design in custom UI components.

Here are the Methods to Change the Position of the Scrollbar using CSS:

Method 1. Using the direction Property

The direction property specifies the text direction of an element's content. Setting it to rtl (right-to-left) moves the scrollbar to the left side.

index.html
<html>
<head>
    <style>
        .scroll-left {
            direction: rtl;
            overflow-y: scroll;
            height: 150px;
            width: 300px;
            border: 1px solid #000;
        }
        .content {
            direction: ltr;
        }
    </style>
</head>
<body>
    <div class="scroll-left">
        <div class="content">
            This is a sample Code 
        </div>
    </div>
</body>
</html>

Code Overview

  • The .scroll-left class applies direction: rtl; to move the scrollbar to the left.
  • The inner .content div resets the text direction to left-to-right with direction: ltr;.

2. Using the transform Property

The transform property can rotate elements, effectively repositioning the scrollbar.

index.hml
<html>
<head>
    <style>
        .scroll-left {
            transform: rotateY(180deg);
            overflow-y: scroll;
            height: 150px;
            width: 300px;
            border: 1px solid #000;
        }
        .content {
            transform: rotateY(180deg);
        }
    </style>
</head>
<body>
    <div class="scroll-left">
        <div class="content">
            This is sample code 
        </div>
    </div>
</body>
</html>

Code Overview

  • The .scroll-left class applies transform: rotateY(180deg); to flip the container, moving the scrollbar to the left.
  • The inner .content div reverses the flip to display content normally.

3. Using overflow-x and transform for Top Scrollbar

To position the scrollbar at the top, combine overflow-x with the transform property.

index.html
<html>
<head>
    <style>
        .scroll-top {
            overflow-x: auto;
            transform: rotate(180deg);
            height: 150px;
            width: 300px;
            border: 1px solid #000;
        }
        .content {
            transform: rotate(180deg);
        }
    </style>
</head>
<body>
    <div class="scroll-top">
        <div class="content">
         This is a sample code 
        </div>
    </div>
</body>
</html>

Code Overview

  • The .scroll-top class applies transform: rotate(180deg); to flip the container, placing the scrollbar at the top.
  • The inner .content div reverses the flip to display content correctly.

Next Article

Similar Reads