我不知道为什么这个悬停不起作用,没有负面的z-index或类似的东西。在最好的情况下,它在悬停时闪烁;
.menu{
border-radius: 50%;
width: 100px;
height: 100px;
background: white;
box-shadow:0 4px 10px 0 rgba(0,0,0,0.2),0 4px 20px 0 rgba(0,0,0,0.19);
background-image: url("home.png");
background-repeat: no-repeat;
background-size: 60% 60%;
background-position: 20px 15px;
position: absolute;
z-index: 1;
}
.menucontent{
height:100px;
width: 400px;
box-shadow:0 4px 10px 0 rgba(0,0,0,0.2),0 4px 20px 0 rgba(0,0,0,0.19);
position: absolute;
display:none;
}
.menu:hover .menucontent{
display: inline;
}
答案 0 :(得分:1)
解决方案1
你可以这样做
.menu:hover ~.menucontent {
display: inline;
}
下面的代码段
.menu {
border-radius: 50%;
width: 100px;
height: 100px;
background: white;
box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.2), 0 4px 20px 0 rgba(0, 0, 0, 0.19);
background-image: url("home.png");
background-repeat: no-repeat;
background-size: 60% 60%;
background-position: 20px 15px;
position: absolute;
z-index: 1;
}
.menucontent {
height: 100px;
width: 400px;
box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.2), 0 4px 20px 0 rgba(0, 0, 0, 0.19);
position: absolute;
display: none;
}
.menu:hover ~.menucontent {
display: inline;
}

<div class="menu" style="left: 100px; top: 100px; ;"></div>
<div class="menucontent" style="left: 150px; top:100px;"></div>
&#13;
答案 1 :(得分:0)
.menucontent
是.menu
的兄弟,因此应使用像~
或+
这样的兄弟选择器来选择
.menu:hover + .menucontent {
display: inline;
}
.menu {
border-radius: 50%;
width: 100px;
height: 100px;
background: white;
box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.2), 0 4px 20px 0 rgba(0, 0, 0, 0.19);
background-image: url("home.png");
background-repeat: no-repeat;
background-size: 60% 60%;
background-position: 20px 15px;
position: absolute;
z-index: 1;
}
.menucontent {
height: 100px;
width: 400px;
box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.2), 0 4px 20px 0 rgba(0, 0, 0, 0.19);
position: absolute;
display: none;
}
.menu:hover + .menucontent {
display: inline;
}
&#13;
<div class="menu" style="left: 100px; top: 100px; ;"></div>
<div class="menucontent" style="left: 150px; top:100px;"></div>
&#13;