gpt4 book ai didi

html - CSS 悬停在边距后面

转载 作者:太空宇宙 更新时间:2023-11-04 04:47:57 25 4
gpt4 key购买 nike

我在页面中间有一个内容区域,我以 margin: 0 auto; 为中心现在我想在带有几个小立方体的页面上产生背景效果,当鼠标悬停时会发生一些变化。

悬停效果在内容区域下方或上方工作正常,但问题是内容居中的边距似乎会干扰悬停的识别,因为当悬停在内容区域边距后面的立方体上时,悬停选择器不起作用。

感谢您的帮助!

编辑:这里有一个代码示例:http://cssdeck.com/labs/dl3ojm0g

最佳答案

CSS 中的一些小改动,效果很好。

    #content {
margin: 0 auto;
position:relative;
margin-top: 50px;
width: 700px;
height: 300px;
padding: 20px;
background-color: white;
border: 2px solid darkgray;
color: darkgray;
z-index:2;
}
#cubeHolder {
position: absolute;
top: 0;
left: 0;
z-index:1;
}

只需要将 #content 定位到 relative 并给它一个比 #cubeHolder 更高的 z-index

示例:http://jsfiddle.net/nwrFa/6/

关于html - CSS 悬停在边距后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14091148/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com