我正在设计一个网站,我想问你们,如何通过 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>
或 <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>
http://jsfiddle.net/jVqDJ/
浏览器支持也很好(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 中一个字符的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!