有没有办法在文本区域内格式化样式和文本?

时间:2015-05-14 07:17:18

标签: html css

您有代码我在文本区域内写入代码以获得如下格式。但我的问题是文本格式正确以及我如何在textarea中放置相同的文本格式。



<input type="textarea">
<P align = center>
<B>About Salman Khan </B>
</P>
<P align = left>Salman Khan (pronunciation  born Abdul Rashid Salim Salman Khan on 27 December 1965)[5] is an INDIAN film actor and producer. He is cited in the media as one of the most commercially successful actors of Hindi cinema.
</P>
<P>
<ul>
	<li>Undertake our tasks and activities in utmost good faith, objectivity, transparency, competence, due care and professionalism.</li>
<li>Abide by the highest standards of politeness and good conduct.</li>
</ul>
</P>
</input>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

抱歉,您无法为textarea设置样式。但是看起来似乎有一些可用的解决方法。这是我发现的第一件事:

Format text in a <textarea>?

所以基本上你把所有的内容放在一个div中并设置它的样式,使它像文本区一样工作。在这里,您可以看到我已将其设为可滚动,可编辑,并设置高度/宽度和边框。 (不需要设置,具体取决于你想要的是什么。)我认为这里最大的问题是不同的浏览器将文本区域设置得不同,所以可能没有那么简单的样式,所以它看起来就像一个原生的所有浏览器中的textarea。

<div id='fake_textarea' style="overflow:scroll; height:100px; width:400px; border:solid; border-width:1px" contenteditable>
    <P align=center>
         <B>About Salman Khan </B>
    </P>
    <P align=left>
        Salman Khan (pronunciation  born Abdul Rashid Salim Salman Khan on 27 December 1965)[5] is an     INDIAN film actor and producer. He is cited in the media as one of the most commercially successful actors of Hindi cinema.
    </P>
    <P>
        <ul>
            <li>Undertake our tasks and activities in utmost good faith, objectivity, transparency, competence, due care and professionalism.</li>
            <li>Abide by the highest standards of politeness and good conduct.</li>
        </ul>
    </P>
</div>

请注意,这与您的代码相同,只是我将input标记替换为样式div

如果您需要在表单中使用此字段,请参阅上述答案中的帖子,并且必须提交内容。这需要一些小工作。

相关问题