如何为文本框中的每个字母插入不同颜色的不同字母 [英] How can i insert different letters with different color for each letter in textbox
问题描述
如何为文本框中的每个字母插入不同颜色的不同字母
表示
a一种颜色
b与其他颜色
字母没有颜色,但HTML元素和字体可以拥有它们。对于常规文本框,这是不可能的,您需要设计或使用非常特殊的控件来执行此操作。对于基本代码示例,请考虑以下事项:
< p contenteditable = true > 这是一个可编辑的段落。 < / p >
(样本取自 http://www.w3schools.com/tags/att_global_contenteditable.asp [ ^ ]。)
如果单击此段并尝试粘贴一些彩色/格式化的片段文本,您将看到不同的颜色和字体将起作用。试试这个:
< p contenteditable = true > 这是一个可编辑的段落。 < span style = color:red > 此文本已着色。< / span > < / p >
我不知道你的目的。想要更严肃或更实用的东西吗?了解一些JavaScript / HTML WYSIWYG编辑器的工作原理,如下所示:
http://en.wikipedia。 org / wiki / TinyMCE [ ^ ],
http://www.tinymce.com/ [ ^ ]。
祝你好运,
-SA
How can i insert different letters with different color for each letter in textbox
means
"a" with one color
"b" with other color
Letters don't have colors, but HTML elements and fonts can have them. This is not possible with "regular" text box, you need to design or use very special control to do this. For a rudimentary code sample, please consider this:
<p contenteditable="true">This is an editable paragraph.</p>
(The sample is taken from http://www.w3schools.com/tags/att_global_contenteditable.asp[^].)
If click on this paragraph and you try to paste some colored/formatted fragment text, you will see that different colors and fonts will work. Try also this:
<p contenteditable="true">This is an editable paragraph. <span style="color:red">This text is colored.</span></p>
I don't know your purpose. Want something more serious or practical? See how some JavaScript/HTML WYSIWYG editor work, like this one:
http://en.wikipedia.org/wiki/TinyMCE[^],
http://www.tinymce.com/[^].
Good luck,
—SA
这篇关于如何为文本框中的每个字母插入不同颜色的不同字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!