【发布时间】:2021-05-27 15:49:16
【问题描述】:
我一直在尝试制作一个弹性盒子,然后当弹性盒子内的内容悬停在上面时,会出现另一个盒子(在它下面,而不是旁边)。出于某种原因,当使用“flex-container”时,这是可行的。但我不希望当人们悬停在两者之间的空间上时发生这种情况。当尝试这样做并专门调用该类时,它是“flex-container-content”,它拒绝工作。出于某种原因,它什么也不做。我什至尝试为它分配一个ID,但它没有用。我不知道我还应该尝试什么,因为对我来说它似乎应该工作。有什么想法吗?
.flex-container {
display: flex;
background-color: white;
margin-left: 5%;
}
.flex-container-content {
background: black;
color: white;
margin: 1%;
font-family: 'Lucida Sans Regular';
font-size: x-large;
padding: 1% 2% 1% 2%;
border-radius: 5px;
}
.flex-container-content:hover{
display: block;
background: rgb(34, 34, 34);
cursor: pointer;
color: rgb(175, 175, 175)
}
#job-descriptor-1 {
display: none;
color: rgb(218, 218, 218);
background: rgb(121, 121, 121);
font-family: 'Lucida Sans Regular';
font-size: large;
padding: 2%;
box-shadow: 0px 0px 3px 0px;
text-align: center;
}
#flex-1:hover + #job-descriptor-1{
display: block;
}
<div class="flex-container">
<div id="flex-1" class="flex-container-content">Police</div>
<div class="flex-container-content">Fast Food</div>
<div class="flex-container-content">Trucker</div>
<div class="flex-container-content">Drug Dealer</div>
<div class="flex-container-content">Post Office Curier</div>
<div class="flex-container-content">Fisherman</div>
</div>
<div id="job-descriptor-1">
Hello there, top of the morning to you.
</div>
【问题讨论】: