How to put the scroll of an element to the left

Asked

Viewed 1,348 times

2

Usually when you use overflow-y: scroll or overflow-y:auto, the scrollbar appears to the right of the element.

.scroll-me{
   height: 80px;
   width: 200px;
   overflow-y: auto;
   overflow-x: hidden;
   font-size: 18px;
}
<div class="scroll-me">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat.
                
                
<br>
Duis aute irure dolor in reprehenderit in voluptate velit esse
                cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
                proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
 </div>

I however need to place a certain element aligned to the right and therefore wish that the scrollbar appears to the left.

How can I do this with css?

1 answer

4

Usa direction: rtl; which is the directive indicating that the content should be interpreted from right to left. In some languages it is written from right to left and this is the norm.

If applicable you can give this directive in the element that has scroll and then give again direction: ltr; in the inner element to restore our stardard.

.scroll-me {
  height: 80px;
  width: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 18px;
  direction: rtl;
}
<div class="scroll-me">
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.


  <br> Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>

  • Man, liked, interesting. But would have how to do without the text align the right?

  • Does not work on safari

  • 2

    @Wallacemaxters text-align: left;

  • 1

    Something new does not work in Safari :p

  • hehehehehehe, it’s true, just for the sake of compatibility

Browser other questions tagged

You are not signed in. Login or sign up in order to post.