首页htmlui_olHTML Element Style - 如何悬停元素来显示孩子

HTML Element Style - 如何悬停元素来显示孩子

我们想知道如何悬停元素来显示孩子。

<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.menuBody {
  display: none;
  background: #ccc;
}

.menuItem {
  background: #aaa;
}

.menuItem:hover {
  background: red;
}

.menuItem:hover .menuBody {
  display: block;
}
</style>
</head>
<body>
  <ul>
    <li class="menuItem">
        <a href="#">MenuItem</a>
      <div class="menuBody">Hover!</div>
    </li>
  </ul>
</body>
</html>