2015-12-28 29 views
2

我發現了一個奇怪的行爲,我無法在<button>元素中選擇文本。作爲一個例子,請嘗試引導這些按鈕來選擇文本:http://getbootstrap.com/components/#list-group-buttons如何用<button>元素中的光標選擇文本?

enter image description here

是它的一些標準行爲還是編輯?我需要選擇按鈕中的文本。

+0

從我的閱讀'*按鈕類型* b utton *沒有默認行爲,因此這可能與瀏覽器有關。可以說,如果文本是可以選擇的......一個按鈕不適合/合適。 –

+0

我可以選擇文字就好了。點擊元素外部並拖動。 – epascarello

+0

@epascarello,是的,對)但它不是一個選項在我的情況 – Green

回答

2

你可以做的this question相反: 創建以下CSS3:

.list-group-item{ 
-webkit-touch-callout: text; 
-webkit-user-select: text; 
-khtml-user-select: text; 
-moz-user-select: text; 
-ms-user-select: text; 
user-select: text; 
} 

和鏈接樣式表。它適用於我的Firefox。

編輯:如Nenad Vracar所說,將「all」改爲「text」。現在它適用於Chrome和Firefox。

+1

不,在Chrome中不起作用,'47.0.2526.106米'。是的,它看起來像是一種瀏覽器行爲。 – Green

-2

您可以像這樣爲按鈕定義css屬性 對於按鈕類添加遊標:pointer屬性。 您可以指定到按鈕直接或您的自定義CSS類

光標:指針

+0

這不會回答*實際詢問的問題* –

2

您可以設置user-select: text

button { 
    -webkit-user-select: text; /* Chrome all/Safari all */ 
    -moz-user-select: text;  /* Firefox all */ 
    -ms-user-select: text;  /* IE 10+ */ 
    user-select: text; 
} 
​​

Fiddle

+1

不,在Chrome中不起作用,'47.0.2526.106 m'。 – Green

相關問題