【问题标题】:Disable DIV selection when clicking on it单击时禁用 DIV 选择
【发布时间】:2013-02-11 12:54:09
【问题描述】:

如何避免选择 div 并在单击时隐藏突出显示?
我想隐藏虚线轮廓:

(无法显示截图,这里是:http://i.stack.imgur.com/3OKaP.png

【问题讨论】:

  • 无法显示图像,但猜测描述已经足够了。谢谢

标签: html css


【解决方案1】:

使用outline:noneoutline:0

查看类似的here

【讨论】:

    【解决方案2】:

    它可以通过一个 css 类来完成。 像。如果这是你的 div :

    <div class='disableSelection'>text</div>
    

    然后应用这个 css。

    <style>
    .disableSelection{
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    outline: 0;
    }
    </style>
    

    【讨论】:

      【解决方案3】:

      这在我的情况下有效:

      元素{

      -webkit-tap-highlight-color: 透明;

      }

      根据 Mozilla Docs

      【讨论】:

        【解决方案4】:

        outline:0; 添加到您的div

        我通常在 IE 上比其他浏览器看到这个问题。

        参考here了解更多信息:

        【讨论】:

          【解决方案5】:

          不确定这是否是您要查找的内容,但请查看Chris Coyers article (Removing The Dotted Outline) on this

          但是,如果您根本不设置替代活动状态,请考虑可用性问题。但我猜克里斯无论如何都会提到这一点。

          【讨论】:

            【解决方案6】:
            *:focus{outline:none}
            
            • 请将此代码添加到您的 css 文件中。这是 CSS 问题

            【讨论】:

              【解决方案7】:

              添加“a”非常重要,表示您正在为链接添加它:

              <style>
              .disableSelection a {
              outline: 0;
              }
              </style>
              

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 2022-06-14
                • 1970-01-01
                • 2021-02-10
                • 1970-01-01
                • 2013-02-25
                • 2014-09-07
                相关资源
                最近更新 更多