用CSS美化按鈕(button)
日期:2013-12-13 來源:攀枝花惠康網絡公司
演示地址:http://www.9demo.com/demo/css_button/css_button.htm
HTML:
<a class=”button” href=http://www.css88.com/archives/”#”><span>按鈕文字</span></a>
CSS:
我們用 A 包含一個 SPAN 標簽來實現此效不美觀:
<style type=”text/css”> a.button { background: transparent url(‘bg_button_a.gif’) no-repeat scroll top right; color: #444; display: block; float: left; font: normal 12px arial, sans-serif; height: 24px; margin-right: 6px; padding-right: 18px; /* sliding doors padding */ text-decoration: none; } a.button span { background: transparent url(‘bg_button_div.gif’) no-repeat; display: block; line-height: 14px; padding: 5px 0 5px 18px; } </style>
為按鈕添加點擊樣式:
CSS:
因為 IE 下點擊后不能還原到默認狀況,是以,我們需要在標簽里添加一段代碼:
HTML: <a class=”button” href=http://www.css88.com/archives/”#” onclick=”this.blur(); return false;”><span>按鈕文字</span></a>
<style type=”text/css”> a.button:active { background-position: bottom right; color: #000; outline: none; /* hide dotted outline in Firefox */ } a.button:active span { background-position: bottom left; padding: 6px 0 4px 18px; /* push text down 1px */ } </style>
設置按鈕樣式:
如不美觀你需要用它提交表單(FORM),那么可以在 onclick 瑯縵沔添加一個提交語句,如:document.forms['theForm'].submit();
文章來源:攀枝花惠康網絡公司
惠康網絡,是一家專業從事攀枝花網站建設,攀枝花網站制作,攀枝花網站設計公司,提供網站建設一條龍服務(網站域名注冊+網站服務器租用+網站開發+網站維護+網站營銷推廣),惠康網絡立足攀枝花,輻射全中國,攀枝花惠康網絡的客戶已經遍布國內各地大中小城市,我們高效優質的網站建設服務深受用戶好評。