页面html图片按钮多种写法

原地址:http://blog.163.com/weison_hi/blog/static/17680404720118534033788/

第一种: 在一般情况下按钮提交表单:

     <form id="form1" name="form1" method="post" action="index.html">
  <input type="submit" name="button" id="button" value="提交" />
   </form>

这样提交按钮是标签 <input type="submit">,如果想换成图片加上样式,把value="提交" 改成value=" "(这样“提交”两个字就不会显示在这张背景图片的上面):

  #button{
 background:url(eeo_2.jpg) no-repeat;
 width:100px;
 height:50px;
 border:0px;
 cursor:pointer;
  }

第二种:直接使用图片标签按钮

<form id="form1" name="form1" method="post" action="index.html">
  <input name="submit" type="image" value="ee" src="eeo_2.jpg" />
</form>

这样子直接写在html页面上就能直接看到按钮是图片的!

 

第三种:由于上面第二种图片直接使用 “src”链接,但是如果一个网站很多需要到表单图片按钮展示的话,这样就会增加网页显示的速度!之前说过如果把全部类型差不多的图片整合成一张,每个页面使用css+div调用同一张图片里面的不同个按钮图标图片,这样的话便能更优化代码以及网站。

<form id="form1" name="form1" method="post" action="index.html">
  <input name="submit" type="image" value="ee" src="eeo_2.jpg" />
</form>
样式:

button{
 background:url(eeo_2.jpg) no-repeat -54px -35px;
 width:100px;
 height:50px;
 border:0px;
 cursor:pointer;
 }

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。