1. 程式人生 > >左側滾動無滾動條

左側滾動無滾動條

在左右分欄中,當左側的過長的時候,如果position是fixed的時候就不會滾動,

<style type="text/css">
    .left{position: fixed;width: 200px; background: gray;top: 0;bottom:0;height: 100%;overflow-x: hidden;}
    .content-border{overflow-x: hidden;width: 220px;height: 100%}
    .left-content{width: 200px;}
    .part1{width: 200px;height: 100
px
;background: red;border:1px solid green;}
</style> <body> <div class="left"> <div class="content-border"> <div class="left-content"> <div class="part1">1</div> <div class="part1">2</div> <div class="part1">3</div> <div
class="part1">
4</div> <div class="part1">5</div> <div class="part1">6</div> <div class="part1">7</div> <div class="part1">8</div> <div class="part1">9</div> <div class="part1">12</div> <div class
="part1">
11</div> <div class="part1">14</div> </div> </div> </div>

主要是外面的content-border 他的3個屬性缺一不可,然後最外層的overflow-x:hidden也是需要的,結果實現了左側的無滾動條滾動