在左侧而不是右侧创建隐藏的溢出

时间:2019-03-28 10:21:19

标签: css css3

我想创建一个轮播。

问题是overflow在右边,而我想在左边;我尝试了right:0,但似乎没有用;

.row { 
width:300px;
}

.carousel { 
max-width: 100%;
position: relative;
white-space: nowrap;
  border: 1px solid red;
}
.container{
  position: relative;
  // overflow: hidden;
  //right:0;
}

.items {
display: block;
left: 0;
position: relative;
top: 0;

}
<div class="row">
<div class="carousel">
  <div class="container">
    <div class="items">
      <a> <img src="https://fakeimg.pl/50x50/"></a>
      <a> <img src="https://fakeimg.pl/50x50/"></a>
      <a> <img src="https://fakeimg.pl/50x50/"></a>
      <a> <img src="https://fakeimg.pl/50x50/"></a>
      <a> <img src="https://fakeimg.pl/50x50/"></a>
      <a> <img src="https://fakeimg.pl/50x50/"></a>
      <a> <img src="https://fakeimg.pl/50x50/"></a>
     </div>
    </div>
 </div
</div>

1 个答案:

答案 0 :(得分:1)

将方向更改为rtl

.row {
  width: 300px;
}

.carousel {
  max-width: 100%;
  white-space: nowrap;
  border: 1px solid red;
}

.items {
  direction:rtl;
}
<div class="row">
  <div class="carousel">
    <div class="container">
      <div class="items">
        <a> <img src="https://fakeimg.pl/50x50/"></a>
        <a> <img src="https://fakeimg.pl/50x50/"></a>
        <a> <img src="https://fakeimg.pl/50x50/"></a>
        <a> <img src="https://fakeimg.pl/50x50/"></a>
        <a> <img src="https://fakeimg.pl/50x50/"></a>
        <a> <img src="https://fakeimg.pl/50x50/"></a>
        <a> <img src="https://fakeimg.pl/50x50/"></a>
      </div>
    </div>
  </div>
</div>