CSS实例(六):实现网页固定大小三态图形按钮简单方法

今天想出一种三态图形按钮实现方式,制作超简单,文字可以随意修改,各种浏览器表现一致,不含任何JS脚本。

  需要一个图片文件:




  网页代码:
Html代码 收藏代码
  1. <?xmlversion="1.0"encoding="GB2312"?>
  2. <!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <htmlxmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <metahttp-equiv="Content-Type"content="text/html;charset=GB2312"/>
  6. <title>firstpage</title>
  7. <styletype="text/css">
  8. /*
  9. bib:bigimagebutton
  10. sib:smallimagebutton
  11. lib:longimagebutton
  12. lsib:longbuttonwithsearchimage
  13. bywallimn,http://wallimn.iteye.com
  14. */
  15. .bib,.sib,.lib,.lsib{
  16. border-width:0;
  17. vertical-align:middle;
  18. background-color:transparent;
  19. margin:0;
  20. overflow:visible;
  21. background-repeat:no-repeat;
  22. background-image:url(buttons.gif);
  23. }
  24. .bib{
  25. width:93px;
  26. height:30px;
  27. line-height:30px;
  28. background-position:0-132px;
  29. }
  30. .bib:hover{
  31. background-position:0-162px;
  32. }
  33. .sib{
  34. width:44px;
  35. height:22px;
  36. line-height:22px;
  37. background-position:00;
  38. }
  39. .sib:hover{
  40. background-position:0-22px;
  41. }
  42. .lib{
  43. width:66px;
  44. height:22px;
  45. line-height:22px;
  46. background-position:0-44px;
  47. }
  48. .lib:hover{
  49. background-position:0-66px;
  50. }
  51. .lsib{
  52. width:66px;
  53. height:22px;
  54. line-height:22px;
  55. background-position:0-88px;
  56. }
  57. .lsib:hover{
  58. background-position:0-110px;
  59. }
  60. /*endofbuttonstyle*/
  61. </style>
  62. </head>
  63. <body>
  64. <inputtype="button"value="按钮"class="sib"/>
  65. <inputtype="button"value="长长按钮"class="lib"/>
  66. <inputtype="button"value="大按钮"class="bib"/>
  67. <inputtype="button"value="搜索"class="lsib"/>
  68. </body>
  69. </html>


   最终效果:




  有个限制,按钮的大小固定成几种尺寸模式,一般来讲,网页上的图形按钮应该也就几种大小,不会有各种各样大小的按钮。固定按钮大小,可以获得非常简洁的代码。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值