我有一个textarea,现在想为用户提供改变字体大小,样式等的工具。当我点击一个按钮时,它应该弹出字体对话框。
<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>
Thanx到Christian textarea现在没有改变...使用类似的方法是可以改变文本字体样式(如粗体,斜体,常规,粗体斜体)和字体面(时间新罗马,lucida手写)??? ?
提前thanx
-subanki
答案 0 :(得分:0)
为了防止尺寸因第二个例子而改变,你需要设置宽度和高度而不是行和列。
<textarea name="txtLayoutViewer" style="width:500px;height:300px"
wrap="off">
Any text u want to see how it changes.
</textarea>
使用适当的CSS可以使它更清洁。