问题
I'm retrieving data from database and display it inside textarea in table format, I try to apply CSS styling for table inside textarea but no effect, does any one know or done this before, please advise, I'm using Javascript editor to the display more like word so user can format the document,
<style type="text/css">
table { }
td,th { white-space:nowrap; padding:3px;color: red; }
.test {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
color: red; }
</style>
<table width="120%" border="0" cellpadding="0" cellspacing="1">
<tr>
<td width=100% valign="top" class="test">Test
<textarea name="txt_letter_body" style="width=100%" rows="50" > <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign=top>
<td class="test">Data</td>
<td align=left colspan=3><font face="Arial, Helvetica, sans-serif" size=3 ></font></td>
</tr>
<tr valign=top>
<td></td>
<td colspan=3><hr noshade size=1 color=#000000></td>
</tr>
</table>
</textarea>
</td>
</tr>
</table>
Is it any possible to apply css for table inside textarea.
回答1:
Most implementations of what you're asking for are somewhat complex. You're basically asking for a WYSIWYG editor if you want styling.
An example would be the comment box like the one on StackOverflow that shows a formatted version below. Another example is TinyMCE that uses a hidden textarea to store the actual text but displays the formatted version in separate markup.
Look at http://tinymce.moxiecode.com/
回答2:
The contexts of a can only be Plain text (including entities). So another approach, in previously indicated, is called for to format the text.
回答3:
finally i found 1 solution, i just add style attributes into table after textarea, which as below
<table width="100%" border="0" style="font-family: arial;">
来源:https://stackoverflow.com/questions/3911558/css-styling-for-table-inside-textarea