2013-02-09 83 views
1

我已經試過這一點,但它不會在文字區域:(情況下工作(在Chrome和IE)關於如何更改textarea選擇顏色的任何想法?

::-moz-selection { 
    background: #b3d4fc; 
    text-shadow: none; 
} 
::selection { 
    background: #b3d4fc; 
    text-shadow: none; 
} 

在那裏有可能進制方式?
CSS或jQuery的任何如何?

+0

其他,你已經已經什麼試過,沒有辦法修改瀏覽器選擇公司陰沉。 – 2013-02-09 11:37:40

+0

嗯我認爲相同,但讓我們看看是否有人有想法.. – john 2013-02-09 11:39:24

回答

0

你試圖改變它裏面的文字textarea或只是顏色的背景顏色如果是後者,那麼這就是你想要什麼?

::-moz-selection { 
    color: #b3d4fc; 
    text-shadow: none; 
} 
::selection { 
    color: #b3d4fc; 
    text-shadow: none; 
} 

正如在這裏看到:http://jsfiddle.net/u6CNN/

順便說一下,您也可以指定background-color

+0

我想你正在試圖在Firefox上變瘦。所以請檢查Chrome或IE – john 2013-02-09 11:46:49

4

這僅在Firefox(和Safari?)中受支持。

您可以做一個解決方法。而不是textarea使用div with contenteditable。

參見:http://jsfiddle.net/VF4tb/1/

+0

我知道它適用於Firefox。但嘗試在Chrome或IE瀏覽器! – john 2013-02-09 11:47:40

+0

改變了我的答案,希望這有助於;) – bpoiss 2013-02-09 12:06:58

+0

它在文本上,但不是在Chrome上的輸入/ textarea ... 是啊contenteditable'll做詭計! – soyuka 2013-02-09 12:07:07

-1

如果我理解正確的話,你想改變一個textarea的背景色,對不對?

是這樣的:

textarea{ 
    /* Change the color of the typed text in the textarea */ 
    color: #CCC; 

    /* Change the background color of the actual textarea */ 
    background-color: #000; 
} 

或類:

CSS->

.classname{ 
    /* Change the color of the typed text in the textarea */ 
    color: #CCC; 

    /* Change the background color of the actual textarea */ 
    background-color: #000; 
} 

HTML的「

<textarea class="classname"> 
</textarea>