代碼如下:
<button value="submit" class="submitBtn"><span>Submit</span></button>
CSS:
程序代碼 代碼如下:
button { border:0; cursor:pointer; font-weight:bold; padding:0 20px 0 0; text-align:center; } button span { position:relative; display:block; white-space:nowrap; padding:0 0 0 20px; } /*blue buttons*/ button.submitBtn { background:url(images/btn_blue_right.gif) right no-repeat; font-size:1.3em; } button.submitBtn span { height:50px; line-height:50px; background:url(images/btn_blue_left.gif) left no-repeat; color:#fff; } button.submitBtn:hover { background:url(images/btn_blue_right_hover.gif) right no-repeat; } button.submitBtn:hover span { background:url(images/btn_blue_left_hover.gif) left no-repeat; }
CSS For IE6和IE7(有時候需要)
代碼如下:
button { width:auto; overflow:visible; } button span { margin-top:1px; }
就像你能看到的那樣,每個狀態使用了2個圖片(總共4個圖片)。進一步簡化,可以將這些狀態轉化為兩個。但這種想法的最初測試出現了不一致的結果。
瀏覽器支持:
IE6,IE7,Firefox(mac/pc),Safari,Opera,Camino等等。
警告:為了使hover在IE6中有效,你將需要編寫一個類觸發器。盡管不像圖片交換一樣糟糕。
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com