【问题标题】:Why are my links in html ul li not working?为什么我在 html ul li 中的链接不起作用?
【发布时间】:2020-05-31 02:29:42
【问题描述】:

我目前正在尝试建立我的第一个网站(家庭作业)。对于我的下拉菜单,我使用了 Dev Ed 的教程作为下拉菜单,它可以正常工作,只是我无法单击下拉位中的链接。 (不过鼠标光标还是变成了那个手形符号)

我该如何解决这个问题?

nav {
  grid-column: 1/5;
  background: #2E3045;
  justify-content: center;
  border-radius: 10px;
}

nav a,
button {
  text-decoration: none;
  font-size: 1.7vw;
  font-family: Bahnschrift, sans-serif;
  color: #DFB830;
  font-weight: bold;
}


/* horizontal-menu */

.menu {
  height: auto;
  display: flex;
  justify-content: space-around;
  align-items: center;
}


/* styling horizontal-menu buttons */

.dropdown button,
.dd-buttons {
  background: none;
  border: none;
  cursor: pointer;
  text-transform: uppercase;
  padding-top: 1%;
  padding-bottom: 1%;
}

.menu button:hover,
.dd-buttons:hover {
  color: #ECEEFF;
}


/* styling the dropdown arrow */

@media only screen and (max-width: 480px) {
  .menu img {
    max-width: 7px;
    height: auto;
    display: inline-block;
  }
}

@media only screen and (min-width: 481px) {
  .menu img {
    max-width: 15px;
    height: auto;
    display: inline-block;
  }
}


/* dropdown list */

.dropdown {
  position: relative;
}

.dropdown ul {
  position: absolute;
  background: #DFB830;
  margin-top: 8px;
  min-width: 150%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  flex-direction: column;
  list-style: none;
  border-radius: 5px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s ease;
  transform: translateY(10px);
}


/* styling dropdown menu list items */

.dropdown li {
  width: 100%;
  height: 100%;
  line-height: 250%;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.4s ease;
}

.dropdown a {
  font-size: 1.5vw;
  color: #2E3045;
}


/* when hovering over dropdown list */

.dropdown li:hover {
  background-color: #E9CF72;
}

.dropdown button:focus+ul {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0px);
}
<!------------------------ menu ------------------------>
<nav>
  <div class="menu">
    <button class="dd-buttons"><a href="https://www.youthduo.com/" target="_blank">YouthDuo</a></button>
    <button class="dd-buttons"><a href="https://www.galacticspirit.com/home.php" target="_blank">Galactic Spirit</a></button>
    <div class="dropdown">
      <button>Feng Shui <img src="images/dropdown icon.png"></button>
      <ul>
        <li><a href="#">Feng Shui Basics</a></li>
        <li><a href="#">CD's and DVD's</a></li>
        <li><a href="#">Books and EBooks</a></li>
      </ul>
    </div>
    <div class="dropdown">
      <button>Color Alchemy <img src="images/dropdown icon.png"></button>
      <ul>
        <li><a href="LIC.html" target="_blank">Living in Color</a></li>
        <li><a href="GT.html">Guided Training</a></li>
        <li><a href="CAB.html">Jami Lin's Products</a></li>
      </ul>
    </div>
  </div>
</nav>

【问题讨论】:

    标签: html css html-lists href


    【解决方案1】:

    删除pointer-events:none

    .dropdown ul {
        position: absolute; 
        background: #DFB830;
        margin-top: 8px;
        min-width: 150%;
        display: flex;
        justify-content: space-around;
        align-items: center;
        flex-direction: column;
        list-style: none;
        border-radius: 5px;
        opacity: 0;
        transition: all 0.4s ease;
        transform: translateY(10px);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-25
      • 1970-01-01
      • 1970-01-01
      • 2014-04-22
      • 2015-06-24
      • 2015-07-31
      相关资源
      最近更新 更多