我有一个正在上班的最终项目,需要在一页上使用表格。长话短说,我希望将鼠标悬停在“联系人”按钮上时显示表单。但是,将鼠标悬停在该表格所占据的空间中时,它会出现。如何从节点的子代without JavaScript上触发时移除悬停事件?这是一个基本的Web创作类,因此除非有必要,否则我不想使用JavaScript。 我也想在.droptainer
上保持过渡。悬停时将display: none
设置为display: block
可以删除过渡,因为无法对display属性进行动画处理。
/* styles for the navigation menu */
nav ul {
list-style: none;
position: relative;
padding: 0;
display: grid;
grid-template: auto / repeat(5, 1fr);
align-content: center;
}
nav ul ul {
display: none;
position: absolute;
top: 100%;
width: 20%;
}
nav ul li:hover > ul {
display: block;
}
nav>ul::after {
content: "";
clear: both;
display: block;
}
nav ul ul li {
float: none;
}
nav ul li a:hover {
color: black;
background-color: orange;
transition: 500ms;
}
nav ul li a {
border: 2px solid gray;
border-radius: 10px;
text-align: center;
display: block;
padding: .7em 0;
text-decoration: none;
background-color: black;
color: floralwhite;
}
/* styles for the dropdown form */
.droptainer {
opacity: 0;
display: block;
position: absolute;
top: 100%;
left: 60%;
margin: 0.5%;
padding: 2em 10%;
background-color: orange;
border: 2px solid gray;
border-radius: 15px;
box-shadow: 5px -5px 12px 4px rgba(0, 0, 0, 0.50);
transform: translatey(-5%);
transition: 600ms 250ms;
}
.drop_btn:hover > .droptainer {
transform: translatey(5%);
opacity: 1;
}
.droptainer:after {
content: "";
position: absolute;
top: -9%;
left: 50%;
width: 50%;
height: 1.75em;
}
<nav class="nav_menu" role="navigation">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="nav/ingredients.html">Ingredients</a>
<ul>
<li><a href="nav/fish.html">Fish</a></li>
<li><a href="nav/vegetables.html">Vegetables</a></li>
<li><a href="nav/condiments.html">Condiments</a></li>
<li><a href="nav/others.html">Others</a></li>
</ul>
</li>
<li><a href="nav/history.html">History</a></li>
<li><a href="nav/trivia.html">Trivia</a></li>
<li class="drop_btn">
<a href="#">Contact</a>
<div class="droptainer">
<h3>Sign up for the latest sushi news</h3>
<form>
<label>Name</label>
<input type="text">
<input type="text">
<label>Email</label>
<input type="text">
<input type="checkbox">
<input type="checkbox">
<label>I want to sign up for SushiNews.</label>
<button>Submit</button>
<button>Reset</button>
</form>
</div>
</li>
</ul>
</nav>
我有一个正在上班的最终项目,需要在一页上使用表格。长话短说,我希望将鼠标悬停在“联系人”按钮上时显示表单。但是,当...
pointer-events: none
,只需设置hidden
:display
设置为none
,然后在悬停时将其简单地设置为block
(切换display
而不是opacity
)。