我有一个文本区,现在想为用户提供方便地改变字体大小,样式等,当我点击一个按钮时,它应该会弹出字体对话框。
<html>
<body>
<form name="abc">
<textarea name="text">loaded text here</textarea>
<input type="button" onClick=""> chnage font
</form>
</body>
</html>我在Lixas的http://www.smokyhosts.com/forums/showthread.php?t=740中发现了这段代码,但当我改变文本大小时,它会改变文本框的高度和宽度
<html>
<head>
<style type="text/css">
body, td, tg, input, select {
font-family: Verdana;
font-size: 10px;
}
</style>
</head>
<body onload="initPosition(document.forms[0].txtLayoutViewer)">
<form>
Change Font Size:
<select onchange="this.form.txtLayoutViewer.style.fontSize = this.options[this.selectedIndex].value; initPosition(this.form.txtLayoutViewer);">
<option value="10">10px</option>
<option value="12">12px</option>
<option value="14">14px</option>
<option value="16">16px</option>
<option value="18">18px</option>
<option value="20">20px</option>
<option value="24">24px</option>
<option value="36">36px</option>
</select>
<textarea name="txtLayoutViewer" rows="15" cols="75" wrap="off">Any text u want to see how it changes.</textarea>
</form></body></html>感谢Christian textarea没有改变now...using类似的方法可以改变文本的字体样式(如粗体,斜体,正则,粗体斜体)和字体(时代新罗马,明快手写)?
提前感谢
-subanki
发布于 2010-07-12 18:53:30
为了防止第二个示例中的大小发生变化,您需要设置宽度和高度,而不是设置行和列。
<textarea name="txtLayoutViewer" style="width:500px;height:300px"
wrap="off">
Any text u want to see how it changes.
</textarea>使用适当的css会让它更整洁一些。
https://stackoverflow.com/questions/3227118
复制相似问题