Change color of one character in a text box HTML/CSS(更改文本框 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> 或 <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 中一个字符的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:更改文本框 HTML/CSS 中一个字符的颜色
基础教程推荐
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
