首页 > Web开发 > 详细

表单label美化代码

时间:2016-01-21 01:20:01      阅读:186      评论:0      收藏:0      [点我收藏+]
化表单,效果如下:
  • 每个lebal有箭头的背景
  • 有焦点的lebal背景高亮

示例如下:

技术分享
代码如下:

复制代码
代码如下:

<form id="commentform" method="post" action="">
<p class="input"><label for="author">姓 名</label><input type="text" aria-required="true" tabindex="1" size="12" value="" id="author" name="author"></p>
<p class="input">
<label for="email">邮 件</label><input type="text" aria-required="true" tabindex="2" size="12" value="" id="email" name="email"></p>
<p><input type="submit" value="提交评论" tabindex="5" id="submit" name="submit"></p>
</form>

css代码:

复制代码
代码如下:

#commentform{
font-size:12px;
}
#commentform label{width:55px;height:24px;display:block;float:left;background:url(label.png) no-repeat left top;line-height:22px;color:#999;padding-left:18px;}
* html #commentform label{float:none;display:inline;padding:5px 15px 10px 18px;margin-right:10px;vertical-align:middle;}
#commentform input{height:20px;width:220px;border:1px solid #EEE;padding:4px 4px 0 4px;}
#commentform p.input:hover label,#commentform p.input:active label,#commentform p.input:focus label{
background:url(label.png) no-repeat left -40px;color:#000;
}
#commentform input#submit{width:82px;height:24px;background:url(submit.png) no-repeat left top;margin-left:73px;color:#999;border:0 none;line-height:100%;display:block;padding:0;cursor:pointer;}
#commentform input#submit:hover,#commentform input#submit:active,#commentform input#submit:focus{background:url(submit.png) no-repeat left bottom;color:#000;}

完整测试代码:



提示:您可以先修改部分代码再运行

请注意图片的地址。

表单label美化代码

原文:http://www.jb51.net/css/26497.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!