【发布时间】:2021-09-01 07:36:03
【问题描述】:
我被这个问题困扰了很多天。我一直在努力实现的是这样的,
我有一个滑块 div 设置它的宽度和高度,在其中我有盒子并排坐着作为孩子。所以我希望隐藏滑块的水平溢出(超出滑块宽度的框)。这可以通过隐藏溢出-x 轻松实现。但问题是当我悬停一个框时,我想扩大它的宽度和高度并显示更多内容,我希望它们垂直溢出滑块。由于隐藏的溢出不起作用。他们也被隐藏了。而且我想扩展该框的宽度和高度而不推动它的兄弟姐妹。示例就像 Netflix 显示它的电影一样。当您将鼠标悬停时,它会展开并显示更多内容。
这是我迄今为止能够实现的目标
.wrapper {
width: 80%;
height: 8rem;
border: 3px solid green;
margin: 4rem auto;
}
.slider {
display: flex;
overflow-x: hidden;
}
.boxes {
display: flex;
height: 100%;
align-items: center;
justify-content: center;
}
.box-container {
position: relative;
}
.box {
width: 8rem;
height: 8rem;
background: purple;
margin-right: 3px;
transition: all 0.4s;
}
.box:hover {
height: 20rem;
width: 15rem;
}
<div class="wrapper">
<div class="slider">
<div class="boxes">
<div class="box-container">
<div class="box"></div>
</div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
</div>
</div>
这就是我想要完成的https://demo.vodlix.com/
【问题讨论】:
标签: html css reactjs slider overflow