当一个div位于另一个div之上并且底部在悬停时滑出时如何设置较低的宽度?
我有一个 div 放在另一个上面。悬停时,底部 div(右侧灰色条)滑出,并且与顶部 div 宽度相同: http:// /d.pr/OB6N。我正在尝试创建带有幻灯片的图像网格。有没有办法将宽度设置为图像中所示的宽度?因为现在,当我检查元素时,宽度是顶部 div 和滑出 div(完全滑出时)的总和。
HTML:
<div class="poster">
<img src="example.png" />
</div>
<div class="bottombox"></div>
CSS:
.poster {
float: left;
width: 250px;
height: 375px;
display: inline-block;
position: relative;
left: 0px;
z-index: 1;
-webkit-transition-duration: 0.2s;
}
.bottombox {
float: left;
width: 250px;
height: 375px;
display: inline-block;
position: relative;
left: -225px;
-webkit-transition-duration: 0.2s;
}
.bottombox:hover {
left: 0px;
}
希望这是有道理的。谢谢!
I have one div on top of another. On hover, the bottom div (the right-side gray bar) slides out and is the same width as the top div: http://d.pr/OB6N. I'm trying to create a grid of images with slide-outs. Is there a way to set the width to be as much as is shown in the image? Because right now, when I inspect the element, the width is the total of the top div and the slide-out div (when fully slid out).
HTML:
<div class="poster">
<img src="example.png" />
</div>
<div class="bottombox"></div>
CSS:
.poster {
float: left;
width: 250px;
height: 375px;
display: inline-block;
position: relative;
left: 0px;
z-index: 1;
-webkit-transition-duration: 0.2s;
}
.bottombox {
float: left;
width: 250px;
height: 375px;
display: inline-block;
position: relative;
left: -225px;
-webkit-transition-duration: 0.2s;
}
.bottombox:hover {
left: 0px;
}
Hope that makes sense. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,如果您创建一个 jsfiddle 来玩,那么帮助您会更容易。也就是说,一种方法是使 .bottombox 成为 .poster 元素的子元素
,然后将 .poster 的 css 更改为
,将 .bottombox 的 css 更改为
,最后将悬停定义设置为
So it would be much easier to help you if you created a jsfiddle to play with. That said, one approach is to make .bottombox a child of the .poster element
then change the css of .poster to
and change the css of .bottombox to
and last set the hover definition to