2015-08-26 84 views
5

我可以更改內容可編輯div中的插入符號的顏色嗎?
光標顏色始終與文本顏色相同,在我的情況下爲紅色。 所以我的問題是,有沒有辦法將插入符的顏色改成黑色? 如caret-color:black HTML:在Contenteditable中更改插入符號的顏色

<div class="red" contenteditable="true"> hello </div> 

CSS:

.red{ 
    color:red; 
    } 

Check this link

+0

檢查此鏈接http://stackoverflow.com/questions/18779354/assign-color-to-mouse-cursor-using-css。它可能會幫助你 –

+0

不,它不會..我的用例是不同的 – Vishu238

+0

你的意思是光標或插入符號? –

回答

-1

您好我想這可能會幫助你的回答

.red{ 
 
    color:red; 
 
} 
 
.red:focus{ 
 
    outline:red; 
 
    border:2px solid red; 
 
}
<div class="red" contenteditable="true"> hello </div>

這裏是演示撥弄工作代碼

Demo code

+0

你有沒有得到我的問題?? – Vishu238

+0

@ Vishu238不完全 –

0

ok.here解決的辦法:) http://codepen.io/anon/pen/avbVzx **

<input id="a" type="text"> 
<input id="b" type="text"> 
#a{ 
color:black; 
-webkit-text-fill-color: red; 
} 
#b{ 
color:red; 
-webkit-text-fill-color: green; 
} 
} 

**

+0

它不會在其他瀏覽器中工作 – Vishu238

1

是。使用現代CSS!

div { 
    caret-color : black; 
} 
相關問題