如何覆盖活动文本光标(Safari)?

时间:2015-12-04 04:40:11

标签: javascript html css safari

我已将光标设置为CSS中的指针。然而,当您在文本上的div内单击并拖动时,光标将更改为文本。 更新:这似乎只发生在Safari(在9.0.1中测试)



#test {
  cursor: pointer;
  background-color:red;
  display:table;
}

<div id="test">testing</div>
&#13;
&#13;
&#13;

3 个答案:

答案 0 :(得分:1)

只需在悬停时使用cursor属性:

    #test:hover {
        cursor: pointer;
    }

答案 1 :(得分:1)

您可以使用:active伪类:

#test {
  cursor: pointer;
  background-color:red;
  display:table;
}
#test:active{
  cursor: auto;/*changes to text-cursor*/
}
<div id="test">testing</div>

答案 2 :(得分:1)

有点JS可以做到:

&#13;
&#13;
document.onmousedown = function () {
    document.getElementById("parent").style.cursor = "pointer"
}

document.onmouseup = function () {
    document.getElementById("parent").style.cursor = "default"
}
&#13;
#test {
  cursor: pointer;
  background-color:red;
  display:table;
}
#parent {
  height: 100px;
  background-color:green;
}
&#13;
<div id="parent"><div id="test">testing</div></div>
&#13;
&#13;
&#13;