我需要用複選框來切換輸入標籤的字體,我嘗試過使用javascript和@ font-face。如何更改輸入的字體?
HTML:
<form action="#" method="post">
<input id="comment-input" type="text" class="form-control input-sm" placeholder="Press enter to post comment">
<span class="input-group-addon sinhala">
Sinhala
<input type="checkbox" aria-label="..." value="si" id="sinhala-toggle-checkbox">
</span>
<button type="button" class="btn btn-sm" data-toggle="tooltip" title="" data-original-title="Mark as read">Post</button>
</form>
<script>
$("#sinhala-toggle-checkbox").click(function(){
$("#comment-input").toggleClass("sinhala");
});
</script>
CSS:
@font-face {font-family: sinhala;
src: url("malithi_web.ttf") format("truetype");
}
.sinhala[type='text']{
font-family: "Malithi web" !important;
font-size:16px;
font-style:normal;
}
只有字體大小的變化,而不是字體 – mzmarkib
順便說一句我試圖從服務器它自己加載字體(自定義) – mzmarkib
你認爲我的瀏覽器/電腦有問題?我甚至嘗試禁用直接寫在鉻上。 – mzmarkib