How to remove the caret from an input element [dup

2019-01-23 11:02发布

This question already has an answer here:

How can I remove the caret from a <input type="text"> element only using CSS and not JavaScript?

2条回答
Melony?
2楼-- · 2019-01-23 11:59

Of course you can do it just with CSS.

Add this code to your CSS file:

border: none;
color: transparent;
text-shadow: 0 0 0 gray;
text-align: center;

&:focus {
    outline: none;
}

Here you have the SOURCE and a DEMO

查看更多
Root(大扎)
3楼-- · 2019-01-23 12:01

I can only say you that you can achieve this by applying the color through css :

<input type="text" style="color: transparent;text-shadow: 0 0 0 red;" />

FIDDLE DEMO

Otherwise there is no way to style the text cursor with CSS.

查看更多
登录 后发表回答