2013-05-17 38 views
10

這個問題CSS rule to disable text selection highlighting顯示如何阻止文本選擇元素。一旦你阻止了選擇,那麼你如何允許選擇一個特定的子元素?例如你如何覆蓋「-moz-user-select:none;」在一個孩子元素?

<div class="no-select"> 
    <p>some text that cannot be selected</p> 
    <p class="select">some text that can be selected</p> 
    <p>some text that cannot be selected</p> 
</div> 

table.no-select{ 
-webkit-touch-callout: none; 
-webkit-user-select: none; 
-khtml-user-select: none; 
-moz-user-select: none; 
-ms-user-select: none; 
user-select: none; 
} 

td.select{-webkit-touch-callout: all !important; 
-webkit-user-select: all !important; 
-khtml-user-select: all !important; 
-moz-user-select: all !important; 
-ms-user-select: all !important; 
user-select: all !important; 
} 

.no-select規則之上的作品,但我在.select規則的企圖沒有,什麼是做這種正確的方法是什麼?

回答

13

嘗試-moz-user-select: text而不是all

作爲未來的參考,每當關注css規則的可能值時,請檢查一個網站,如MDN

Hereuser-select的MDN鏈接。

+1

非常感謝:) –