如何更改光标颜色而不更改文本颜色?

时间:2011-04-11 00:25:26

标签: html css

我希望光标#FFF,而我的字体是#000

这可能吗?

5 个答案:

答案 0 :(得分:10)

You can make a custom one

input, textarea {
    cursor: url(cursor.cur);
}

答案 1 :(得分:4)

是的,这很容易。正常设置字体颜色然后使用自定义光标。

http://beradrian.wordpress.com/2008/01/08/cross-browser-custom-css-cursors/

这取决于自定义光标是否为彩色,我只是假设它可以。

答案 2 :(得分:2)

来自mozilla docs

/* Keyword values */
caret-color: auto;
caret-color: transparent;
caret-color: currentColor;

/* <color> values */
caret-color: red;
caret-color: #5729e9;
caret-color: rgb(0, 200, 0);
caret-color: hsla(228, 4%, 24%, 0.8);

答案 3 :(得分:1)

change caret color CSS的输入类型文本和textarea使用下面的css

input,textarea {
     color: #8f0407;
     text-shadow: 0px 0px 0px #000 ;
     -webkit-text-fill-color: transparent ;
}

input::-webkit-input-placeholder,
     textarea::-webkit-input-placeholder {
     color: #ccc;
     text-shadow: none;
     -webkit-text-fill-color: initial;
}

Codepen Demo

答案 4 :(得分:0)

试试这个

<style>
input {
  color: rgb(60, 0, 248);  /* change [input cursor color] by this*/
  text-shadow: 0px 0px 0px #D60B0B; /* change [input font] by this*/
  -webkit-text-fill-color: transparent;
}
</style>