Home  >  Article  >  Web Front-end  >  An example of a button implemented with a picture using CSS

An example of a button implemented with a picture using CSS

墨辰丷
墨辰丷Original
2018-05-09 18:23:041887browse

This article mainly introduces how to use CSS to implement a button example of a picture. It is easy to use and mysterious. It is worth collecting and sharing. Reading the image coordinate system through CSS to implement a local background image is a reference for interested friends. one time.

The NetEase 126 login button code is as follows:

<style> 
.inp_L1,.inp_L2,{background:url(/upload/20080515201218970.jpg) no-repeat} 
.inp_L1{ width:67px; height:23px; background-position:-4px -4px; border:0; color:#464646; line-height:23px} 
.inp_L2{ width:67px; height:23px; background-position:-4px -30px; border:0; color:#464646; line-height:23px} 
</style> 
<input type="submit" value="登 录" class="inp_L1" onMouseOver="this.className=&#39;inp_L2&#39;" onMouseOut="this.className=&#39;inp_L1&#39;" id="input_btn1"  name="enter.x" tabindex="4">

The navigation button code is as follows:

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>用CSS实现的一张图完成的导航条</title> 
<style> 
ul,li{ list-style:none; float:left;} 
body{ font-size:12px; line-height:1.6; font-family:Verdana, "宋体", Arial; text-align:center;} 
#info li{ margin-left:4px; margin-top:15px;} 
#info a {display:block;text-align:center; padding-left:15px; 
padding-top:2px;padding-bottom:1px;background-image:  
url(/upload/20080515201218783.GIF); 
background-repeat: no-repeat;color: #000; width:47px; cursor:hand; text-decoration: none;} 
#job a:link,#job a:visited{background-position: -62px 0px;} 
#eve a:link,#eve a:visited{background-position: -124px 0px;} 
#oth a:link,#oth a:visited{background-position: -186px 0px;} 
#car a:hover ,#car a:active {background-position: 0px -22px; color:#fff;} 
#job a:hover ,#car a:active {background-position: -62px -22px; color:#fff;} 
#eve a:hover ,#car a:active {background-position: -124px -22px; color:#fff;} 
#oth a:hover ,#car a:active {background-position: -186px -22px; color:#fff;} 
</style> 
</head> 
<body>  
<div id="info"> 
 <ul> 
  <li id="car"><a href="#" target="_blank"><span> 
 游 戏</span></a></li> 
  <li id="job"><a href="#" target="_blank"><span> 
 娱 乐</span></a></li> 
  <li id="eve"><a href="#" target="_blank"><span> 
 菜 单</span></a></li> 
  <li id="oth"><a href="#" target="_blank"><span> 
 好 玩</span></a></li>    
 </ul>  
</div> 
</body> 
</html>


Related recommendations:

CSS to achieve 3D button effect

AngularJS development WebApp to achieve highlighting Jump button effect, how to use ui-sref and ui-sref-active

css3 Recommended articles to achieve 3D button effect

CSS3 Display horizontal scrolling menu button effect code

The above is the detailed content of An example of a button implemented with a picture using CSS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn