Jquery Material Form Plugin是一款基於Bootstrap的Material Design風格的jQuery表單插件。該表單通過自定義樣式和jQuery來將Bootstrap的表單修改為扁平風格的表單,並帶有浮動標籤特效。
在線預覽源碼下載
使用方法
使用該Material Design風格表單需要在頁面中引入jquery,bootstrap相關文件和materialFormStyles.css、materialForm.js文件。
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css"><link rel="stylesheet" href="css/materialFormStyles.css"><script src="js/jquery.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script><script src="js/materialForm.js"></script>
HTML結構
該Material Design風格表單的HTML結構是固定的,你可以復制下面的代碼。
<div id="formOutterWrapper"><div id="formInnerWrapper"><form id="materialForm" method="post" action="" role="form" autocomplete="off"><div><div><label for="firstName">用戶名稱</label><input type="text" id="firstName" name="firstName"></div><div><label for="lastName">暱稱</label><input type="text" id="lastName" name="lastName"></div></div><div><div><label for="email">電子郵件</label><input type="text" id="email" name="email"></div><div><label for="phone">聯繫電話</label><input type="tel" id="phone" name="phone"></div></div><div><div><label for="description">項目描述</label><input type="text" id="description" name="description"></div></div><div><div><button type="button" id="submit">提交</button></div></div></form></div></div>
該表單插件的github地址為:https://github.com/ch0chi/Jquery-Material-Form-Plugin