[英]Styling submit buttons — Rails app
我一直在嘗試在提交按鈕中放入超棒的字體或glyphicon(甚至圖片)。 這很快就消失了,我需要實現另一種選擇。 我已經看到了幾種方法,但是我不知道哪種是“正確的”或更好的方法。
我見過的三個競爭者是:
在“提交”按鈕中獲取圖像/圖標的最佳方法是哪種?
這三個人都不需要一個JS組件嗎?
這是引導程序如何將glyphicon添加到按鈕對象:
<button type="button" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-star" aria-hidden="true"></span> Star
</button>
button選項不需要JS。 我已經對其進行了測試,您可以在這里https://jsfiddle.net/mikhailjan/sf9s28et/5/上看到一個使用Font Awesome的工作示例,或者只看下面的代碼:
<form action="add_person.php">
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<button type="submit" class="button">
<i class="fa fa-user-plus"></i> Add Person
</button>
</form>
Jonathan Anctil是正確的,該按鈕需要type="submit"
才能使表單正常工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.