phpStudy
phpStudy
网站首页
软件下载
PHP教程
编程技术
PHP
MySQL
HTML
CSS
JavaScript
MSSQL
AJAX
.NET
JSP
window
Linux
Mac
ASP
服务器
CMS
SQL
jQuery
C#
C++
java
Android
IOS
oracle
MongoDB
PostgreSQL
SQLite
教程手册
php
html
html5
css
css3
JavaScript
ajax
jquery
sql
ado
asp
aspnet
browsers
careers
dhtml
dotnetmobile
dtd
e4x
glossary
hosting
htmldom
json
media
msnet
quality
rdf
rss
schema
semweb
site
sitemap
smil
soap
svg
tags
tcpip
vbscript
w3c
wap
web
webservices
wmlscript
wsdl
xforms
xhtml
xlink
xml
xmldom
xpath
xquery
xsl
xslfo
网站测速
小皮面板
智能dns
搜索
首页
PHP教程
表单label美化代码
表单label美化代码
化表单,效果如下:
每个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;}
完整测试代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>label 美化</title> <style type="text/css"> #commentform{ font-size:12px; } #commentform label{width:55px;height:24px;display:block;float:left;background:url(http://files.phpstudy.net/demoimg/201005/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(http://files.phpstudy.net/demoimg/201005/label.png) no-repeat left -40px;color:#000; } #commentform input#submit{width:82px;height:24px;background:url(http://files.phpstudy.net/demoimg/201005/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(http://files.phpstudy.net/demoimg/201005/submit.png) no-repeat left bottom;color:#000;} </style> </head> <body> <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> </body> </html>
提示:您可以先修改部分代码再运行
请注意图片的地址。
«
»
PHP教程
PHP简介
PHP基本语法
PHP类型
PHP变量
PHP运算符
PHP控制结构
PHP函数
PHP类与对象
PHP异常处理
函数库分类
快速导航
PHP
MySQL
HTML
CSS
JavaScript
MSSQL
AJAX
.NET
JSP
Linux
Mac
ASP
服务器
SQL
jQuery
C#
C++
java
Android
IOS
oracle
MongoDB
SQLite
wamp
交通频道
Copyright © 2016 phpStudy | 豫ICP备2021030365号-3