【问题标题】:How remove underline from img a link dropdown in table?如何从 img 表格中的链接下拉列表中删除下划线?
【发布时间】:2018-01-26 17:09:33
【问题描述】:

我已经尝试使用 text-decoration:none 来删除下划线,但我无法让它自行删除。

这是我的 HTML...

.dropdown {
  position: relative;
  display: inline-block;
  text-decoration: none;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 220px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
  text-decoration: none;
}

.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-decoration: none;
}

.dropdown-content a:hover {
  background-color: #f1f1f1;
  text-decoration: none;
}

.dropdown:hover .dropdown-content {
  display: block;
  text-decoration: none;
}

.dropdown:hover .dropimg {
  background-color: #3e8e41;
  text-decoration: none;
}

img.dropimg {
  text-decoration: none;
}

td.table_data.dropdown .image-link {
  text-decoration: none;
}

a:link {
  text-decoration: none!important;
}

a:hover {
  text-decoration: none;
  box-shadow: none;
}

td.table_data.dropdown a.image-link {
  text-decoration: none!important;
}
<td class="table_data dropdown">
  <a class="image-link" href="/somelink"><img class="dropimg" src="img/address_book.png" alt="contact" height="25px" width="25px">
    <div class="dropdown-content">
      <a href="#">Name: Blah</a>
      <a href="#">DoB: Blah2</a>
    </div>
  </a>
</td>

也许我的 CSS 不够具体,但我不知道从哪里开始。自然,我希望它可以在大多数现代浏览器上运行。我们通常在部署此站点的内部使用 IE、Edge、Firefox 和 Chrome。

任何建议将不胜感激;谢谢。

【问题讨论】:

标签: html css image dropdown underline


【解决方案1】:

将文本装饰设置为 a 标签本身。

 a{text-decoration: none;}

您不想嵌套标签,请使用 li 或按钮作为下拉菜单。

【讨论】:

  • 这不起作用,但谢谢。我找到了不同的解决方案;见上文。
【解决方案2】:

这个解决方案对我有用:

<td class="table_data">
    <a style="text-decoration:none;"
       title="Name: blah1&#10DoB: Blah2&#10"
       href="/some-link/">
        <img class="dropimg" src="{% static "img/address_book.png" %}" alt="contact" height="20px" width="20px">
    </a>
</td>

【讨论】:

  • 这与我给出的答案相同,大声笑不要嵌套 a 标签,并将 text-decoration:none 应用于标签。
  • 我不明白你的评论@Paulie_D 因为锚点确实有一个 href 并且答案中只有一个锚点(我认为锚点是指 a 元素)。
  • 您更改了编辑,在 a 标签中嵌套了 2 个标签。 @Paulie_D 是对的。您的结构是不正确的 HTML。不听话很难解决问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-11-10
  • 2022-08-12
  • 2017-03-17
  • 2013-11-10
  • 2012-06-06
  • 1970-01-01
  • 2011-02-16
相关资源
最近更新 更多