在文本框HTML / CSS中更改一个字符的颜色 [英] Change color of one character in a text box HTML/CSS
问题描述
我在设计一个网站,我想问你们,如何在CSS的HTML文本框中更改字符串中的一个字符的颜色?
I'm designing a web site and i would like to ask you guys that, how can I change the color of just one character in a string in a text box of HTML by CSS?
示例:STACK OVER FLOW只是'A'字母是红色的!
example : STACK OVER FLOW just the 'A' letter is red!
推荐答案
您不能使用常规< input type =text>
或< textarea>
元素,但使用普通元素(如< div>
c code>< p> )创建了 contenteditable
,您拥有html / css格式的所有自由。
You can't do this with a regular <input type="text">
or <textarea>
element, but with a normal element (like <div>
or <p>
) made contenteditable
, you have all the freedoms of html/css formatting.
<div contenteditable>
ST<span style="color: red">A</span>CK OVERFLOW
</div>
浏览器支持也很好(IE5.5 +)。有关详情,请访问 https://developer.mozilla.org/en-US/docs/Web/HTML / Content_Editable
The browser support is very good as well (IE5.5+). Read more at https://developer.mozilla.org/en-US/docs/Web/HTML/Content_Editable
这篇关于在文本框HTML / CSS中更改一个字符的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!