How to position a div scrollbar on the left hand side?

前端 未结 7 1094
别跟我提以往
别跟我提以往 2020-12-01 00:38

Is it possible to specify a position (left or right hand side) for the placement of a vertical scrollbar on a div?

For example look at this page which explains how

7条回答
  •  生来不讨喜
    2020-12-01 01:24

    Kind of an old question, but I thought I should throw in a method which wasn't widely available when this question was asked.

    You can reverse the side of the scrollbar in modern browsers using transform: scaleX(-1) on a parent

    , then apply the same transform to reverse a child, "sleeve" element.

    HTML

    CSS

    .parent {
      overflow: auto;
      transform: scaleX(-1); //Reflects the parent horizontally
    }
    
    .sleeve {
      transform: scaleX(-1); //Flips the child back to normal
    }
    

    Note: You may need to use an -ms-transform or -webkit-transform prefix for browsers as old as IE 9. Check CanIUse and click "show all" to see older browser requirements.

提交回复
热议问题