How to scroll an element to the left

2

Normally when using overflow-y: scroll or overflow-y:auto , the scroll bar 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 put a certain element right-aligned, so I wish the scrollbar appears to the left.

How can I do this with css?

    
asked by anonymous 14.04.2017 / 18:28

1 answer

4

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

If this is the case, you can give this directive in the element that has the scroll and then give 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>
    
14.04.2017 / 18:31