HTML Text area with custom user font size style and colour -
How do I create a text field in HTML where the user can change the font style, size and color I am about an hour Have not taken any advantage. I can get simple text boxes, where the user can input the data, but not where they can change the font size style and color
thanks
< Div class = "post-text" itemprop = "text">
Very basic, you may need to type some javascript.
You might be a dropdown, which shows the font size from 4px to 30px, for example. Example:
& lt; Textarea id = "textarea1" & gt; Test 123 & lt; / Textarea & gt; & Lt; Select onchange = "textarea1.style.fontSize = this.value;" & Gt; & Lt; Option value = "12px" selected = "selected" & gt; 12px & lt; / Option & gt; & Lt; Option value = "4px" & gt; 4px & lt; / Options & gt; & Lt; Option value = "30px" & gt; 30px & lt; / Options & gt; & Lt; / Select & gt; To change the background color, the onchange code will be textarea1.style.backgroundColor = this.value; with redundant values for # ff0000 , # 00ff00 green and so on. To change the style, you might need something like a statement:
if (This.value == 'U') textarea.style.textDecoration = ' Underline '; Else textarea.style.textDecoration = ''; If (this.value == 'i') textarea.style.fontStyle = 'italic'; Else textarea.style.fontStyle = 'normal'; If (this.value == 'b') textarea.style.fontWeight = 'bold'; Else textarea.style.fontWeight = ''; However, you may need to customize the code slightly to meet composite styles like bold italics.
Comments
Post a Comment