文本属性输入框,用于选择字体
text properties input box for chosing a font
http://protected-river-1861.herokuapp.com/
我有对齐,颜色,大小和宽度,但我需要至少再添加一个。是否可能有一个字体输入框,用户可以在其中选择要使用的字体?
<p>Hover over the control names to see some useful tips</p>
<span class="simple-tooltip" title="Use this control to choose the horizontal position of the text">Horizontal: <input type="number" value="10" id="left">
<span class="simple-tooltip" title="Use this control to choose the vertical position of the text">Veritcal: <input type="number" value="10" id="top">
<span class="simple-tooltip" title="Use this control to choose the width of the text">Width: <input type="number" value="400" id="width">
<span class="simple-tooltip" title="Use this control to choose size of the text">Size: <input type="number" value="32" id="size">
<span class="simple-tooltip" title="Use this control to choose the colour of the text
JS:
$(document).on('input', '#text', function() {
$("#caption").text($(this).val());
});
$(document).on('change', '#left', function() {
$("#caption").css("left", $(this).val() + 'px');
});
$(document).on('change', '#top', function() {
$("#caption").css("top", $(this).val() + 'px');
});
$(document).on('change', '#width', function() {
$("#caption").css("width", $(this).val() + 'px');
});
$(document).on('change', '#size', function() {
$("#caption").css("font-size", $(this).val() + 'px');
});
$(document).on('change', '#colour', function() {
$("#caption").css("color", $(this).val());
});
这是可能的。你可以有一个额外的选择元素,并改变font-family
属性,因为你正在做额外的CSS属性。
示例代码将是这样的: