【问题标题】:pointer-events on a href Internet Explorerhref Internet Explorer 上的指针事件
【发布时间】:2015-02-20 18:57:58
【问题描述】:

我在 Internet Explorer 中看到了在 SVG 上使用指针事件的方法,但对于一个项目,我需要更改 a href(指针事件:无)。我该怎么做?

(我无法更改代码,只能添加 CSS)

谢谢! :)

【问题讨论】:

  • 如果您查看caniuse,您会发现ponter-events 在IE11 中对links 不起作用
  • 连一小段js代码都没有?
  • 我可以添加 JS,但前提是我不更改 a href's(我不能在其上放置 ID/Class 或其他)
  • 请提供 html 并准确说明您要禁用哪些链接
  • (指针事件:a 上没有)

标签: html css internet-explorer


【解决方案1】:

如果您尝试禁用此菜单中的所有链接,则有一个 CSS 选项涉及覆盖锚链接的 li 上的 ::after 伪元素。

最佳解决方案是 javascript。

如果您想定位特定的列表项/锚组合,您可以使用相同的技术,使用 nth-child。

 li:nth-child (insert your number here)

基于给定的结构。

#custom-nav-inner {
    display: inline-block;
}
#custom-nav-inner li {
    list-style-type: none;
    position: relative; /* positioning context */
}
#custom-nav-inner li a {
    display: block;
    background: #bada55;
    padding:0.25rem 1rem;
}

#custom-nav-inner li a:hover {
    background: #f06d06;
}
#custom-nav-inner li::after {
    content: '';
    position: absolute;
    top:0;
    left: 0;
    width: 100%;
    height: 100%;

}
<div id="custom-nav-inner">
    <ul>
        <li><a href="/">Home</a>

        </li>
        <li><a href="/the-device">The Device</a>

        </li>
        <li><a href="/musthaves.html">Musthaves</a>

        </li>
    </ul>
</div>

【讨论】:

  • 我最终将一些 jQuery 粘贴到:$(function(){ $('#custom-nav a, .footer-container a, .footer-end a').click(function() {返回假;});}); (我想编辑的那个)虽然 Paulie_D 他的方式也很好:)
猜你喜欢
  • 2012-03-12
  • 2020-05-21
  • 2012-05-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-01
  • 2013-02-26
相关资源
最近更新 更多