如何将文本框(多行)中的文本设为粗体,斜体,下划线......?
问题描述:
你好朋友,
如何输入粗体文字..点击粗体按钮后..
不仅粗体..我想要它用斜体,下划线,字体颜色...
i想要它在自定义按钮.canu请帮助我。
Hello Friends,
how to type the text in bold ..after clicking the bold button..
Not only bold..i want it in italic,underline,font color...
i want it in customize button .canu please help me.
答
这是使用css属性font-weight
等完成的 - http://www.w3schools.com/cssref/pr_font_weight.asp [ ^ ]。
多行 - https://css-tricks.com/multi-line-padded-text/ [ ^ ]
This is done using css propertiesfont-weight
etc - http://www.w3schools.com/cssref/pr_font_weight.asp[^].
Multi-line - https://css-tricks.com/multi-line-padded-text/[^]
问题不明确。您可能不仅要编辑文本,还要编辑格式化文本。比方说,文本的一部分是粗体,其他部分有不同的字体大小,不同的缩进等等。
这些编辑器不是基于输入而创建的control(你称之为textbox实际上是 input 元素),但是一些元素,例如div
,属性为contenteditable
:
https: //developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_Editable [ ^ ],
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/contentEditable [ ^ ]。
可以编辑这些元素由用户。您还可以使用一些控件,使用JavaScript修改所选文本片段的样式属性。这是像其他格式化文档编辑器一样开发行为的方法。
这是其中一个产品的一个很好的例子:开源TinyMCE:
https://en.wikipedia.org/wiki/TinyMCE [ ^ ],
http://www.tinymce.com/ [ ^ ]。
还有更多: https: //en.wikipedia.org/wiki/Comparison_of_HTML_editors [ ^ ]。-SA
The question is not clear. It's possible that you want edit not just text, but formatted text. Say, part of text would be bold, some other part have different font style of size, different indent, and so on.
Such editors are created based not on input control (what you call "textbox" is actually the input element), but some element, such asdiv
with the attributecontenteditable
:
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_Editable[^],
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/contentEditable[^].
Such elements can be edited by the users. You can also have some controls which modify the style properties of the selected fragment of text using JavaScript. This is the way to developed the behavior like in other the formatted document editors.
This is a good example of one of such products: open-source TinyMCE:
https://en.wikipedia.org/wiki/TinyMCE[^],
http://www.tinymce.com/[^].
There are many more: https://en.wikipedia.org/wiki/Comparison_of_HTML_editors[^].—SA