網頁執行個體:用CSS製作帶有樣式的網頁按鈕

來源:互聯網
上載者:User

今天把公司平台中前設計師做的按鈕部分重新設計了下,原先他使用的JS實現圖片交替變化的方式,但那樣的缺點是:佔用了input裡的ID屬性,而且disabled也不能使用,不利於程式的設計製作。
按鈕重新製作的思想:
1、實現觸發與不觸發之間的差別;
2、適用input和a;
3、多種瀏覽器下無差別。
按鈕重新製作的過程:
1、利用不同樣式實現觸發與不觸發之間的差別;
2、利用boder來類比按鈕陰影
以下代碼在IE6、IE7、FF下測試正常!
CSS部分:

 代碼如下 複製代碼
.button-style01{
 color:#5E7384;
 font-weight: bold;
 background:#CBDBE5;
 border-top:1px solid #f1f1f1;
 border-left:1px solid #f1f1f1;
 border-right:2px solid #666;
 border-bottom:2px solid #666;
 height: 25px
}
.button-style02{
 color:#fff;
 font-weight: bold;
 background: #859BAB;
 border:1px solid #f1f1f1;
 border-top:1px solid #f1f1f1;
 border-left:1px solid #f1f1f1;
 border-right:2px solid #666;
 border-bottom:2px solid #666;
 height: 25px
}
a.button-style01,a.button-style02 {
 display:block;
 height:22px;
 line-height:22px;
 vertical-align:middle;
 padding:0px 8px;
}
a.button-style01:link,a.button-style01:visited {
 text-decoration:none;
 color:#5E7384;
 border-top:1px solid #f1f1f1;
 border-left:1px solid #f1f1f1;
 border-right:2px solid #666;
 border-bottom:2px solid #666;
}
 
a.button-style02:hover,a.button-style02:active {
 text-decoration:none;
 color:#fff;
 border-top:1px solid #f1f1f1;
 border-left:1px solid #f1f1f1;
 border-right:2px solid #333;
 border-bottom:2px solid #333;
}
xhtml部分:
<input type="submit" name="login" id="login" onclick="myoffice.submit()" value="Sign in" onmouseover="this.className='button-style02'" onmouseout="this.className='button-style01'" class="button-style01" style="width:70px;" />
<a href="#" onmouseover="this.className='button-style02'" onmouseout="this.className='button-style01'" class="button-style01">Join Free</a>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.