作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
大家好,我有两张悬停图像。在 div 中,它们当前位于图像重叠中,两者都从 div 的顶部开始,而不是在其旁边。 example
<div class="storyboard">
<div class="storycard" >
<img src="Images/Articles/Index/world%20cup2.jpg" class="primary">
<img src="Images/Articles/Index/world%20cup.jpg" class="secondary">
</div>
<div class="storycard">
<img src="Images/Articles/Index/ntci2.jpg" class="primary">
<img src="Images/Articles/Index/ntci1.jpg" class="secondary">
</div>
和我的CSS
.storyboard{
width: 100%;
padding: 30px;
}
.storycard{
position: relative;
float: left;
}
.storycard img{
position: absolute;
margin: 0 auto;
}
.storycard .secondary:hover {
position: absolute;
top: 0;
-webkit-transition: all 200ms ease-in-out;
-moz-transition: all 200ms ease-in-out;
-o-transition: all 200ms ease-in-out;
-ms-transition: all 200ms ease-in-out;
transition: all 200ms ease-in-out;
-webkit-opacity: 0;
-moz-opacity: 0;
opacity: 0;
display: block;
}
由于 .storycard .secondry:hover 因为它是我无法使 .storycard img 相对于其他方式我得到 this .谢谢。
最佳答案
首先将所有 div
元素包含在 #wrapper
中。
并将#wrapper
的display
设置为display:inline-block;
#wrapper{
width: 100%;
padding: 30px;
display:inline-block;
}
然后给 #wrapper
中的两个 div
元素赋予不同的 class
查看Demo
关于html - 如何让div落在前一个div旁边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25159748/
我是一名优秀的程序员,十分优秀!