下拉菜单消失得太快

Drop down menu disappears too quicky

当我将 top: 2rem 设置为 dropdown-content 时,它工作正常但看起来不太好。

它在 3rem 下看起来确实不错,但是当我悬停它时下拉菜单就消失了。我试过 :focus 和 :active 还是一样。

body {
  display: grid;
  place-content: center;
}

.consumer-header__menu-label {
  position: relative;
  cursor: pointer;
  display: flex;
  padding: 0 1rem;
}

.dropdown-content {
  position: absolute;
  top: 3rem;
  right: 0;
  display: none;
  background-color: #ffffff;
  width: 260px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

.eds-dropdown-menu__contents:hover .dropdown-content {
  display: block;
}
<div class="consumer-header__menu">
  <div class="dropdown-menu">
    <div class="eds-dropdown-menu__contents">
      <div class="consumer-header__menu-label">
        <div class="dropdown-content">
          <li>Why Eventbrite?</li>
          <li>Pricing</li>
          <li>Resources</li>
        </div>
        Organize
        <span class="eds-dropdown-menu__icon">
           Custom Icons Component
        </span>
      </div>
    </div>
  </div>
</div>

为此我会使用原生 HTML <details> element:

body {
  display: grid;
  place-content: center;
}

details {
  min-width: 260px;
}

details:hover, summary:focus {
  cursor: pointer;
  background-color: #eee;
}

details ul {
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
<div class="consumer-header__menu">
  <div class="dropdown-menu">
    <div class="eds-dropdown-menu__contents">
      <details>
        <summary>Organize</summary>
        <ul>
          <li>Why Eventbrite?</li>
          <li>Pricing</li>
          <li>Resources</li>
        </ul>
      </details>
    </div>
  </div>
</div>