以下是 CSS3表单突出强调特效js代码 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Enhance Required Form Fields with CSS3</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Enhance Required Form Fields with CSS3" />
<meta name="keywords" content="form, html5, css3, animated, transition, required, filter" />
<meta name="author" content="Codrops" />
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript" src="js/modernizr.custom.04022.js"></script>
<!--[if lt IE 8]>
<style>
.af-wrapper{display:none;}
.ie-note{display:block;}
</style>
<![endif]-->
</head>
<body>
<div class="container">
<!-- Codrops top bar -->
<div class="codrops-top">
<a href="http://tympanus.net/Tutorials/CSS3FluidParallaxSlideshow/">
<strong>« Previous Demo: </strong>Fluid CSS3 Slideshow with Parallax Effect
</a>
<span class="right">
<a href="http://tympanus.net/codrops/2012/05/02/enhance-required-form-fields-with-css3/">
<strong>Back to the Codrops Article</strong>
</a>
</span>
<div class="clr"></div>
</div><!--/ Codrops top bar -->
<header>
<span>Tips & Tricks</span>
<h1>Enhance Required Form Fields <span>with CSS3</span></h1>
<nav class="codrops-demos">
<a class="current-demo" href="index.html">Color</a>
<a href="index2.html">Hide (scale)</a>
<a href="index3.html">3D</a>
</nav>
<p>Click on the button to enhance required fields or de-emphasize/hide optional ones.</p>
<p class="ie-note">D'oh!</p>
</header>
<section class="af-wrapper">
<h3>Random Form</h3>
<input id="af-showreq" class="af-show-input" type="checkbox" name="showreq" />
<label for="af-showreq" class="af-show">Enhance required fields</label>
<form class="af-form" id="af-form" novalidate>
<div class="af-outer">
<div class="af-inner">
<label for="input-title">Title</label>
<input type="text" name="title" id="input-title">
</div>
</div>
<div class="af-outer af-required">
<div class="af-inner">
<label for="input-name">Name</label>
<input type="text" name="fullname" id="input-name" required>
</div>
</div>
<div class="af-outer af-required">
<div class="af-inner">
<label for="input-email">Email address</label>
<input type="email" name="email_address" id="input-email" required>
</div>
</div>
<div class="af-outer">
<div class="af-inner">
<label for="input-bdate">Birth Date</label>
<input type="date" name="birthdate" id="input-bdate" placeholder="MM/DD/YYYY">
</div>
</div>
<div class="af-outer af-required">
<div class="af-inner">
<label for="input-country">Country</label>
<input type="email" name="country" id="input-country" required>
</div>
</div>
<div class="af-outer">
<div class="af-inner">
<label for="input-catname">Your cat's name</label>
<input type="email" name="catsname" id="input-catname">
</div>
</div>
<div class="af-outer">
<div class="af-inner">
<label for="input-phone">Phone Number</label>
<input type="email" name="phonenumber" id="input-phone">
</div>
</div>
<input type="submit" value="Send it over!" />
</form>
</section>
</div>
</body>
</html>
HTML代码(index2.html):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Enhance Required Form Fields with CSS3</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Enhance Required Form Fields with CSS3" />
<meta name="keywords" content="form, html5, css3, animated, transition, required, filter" />
<meta name="author" content="Codrops" />
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<link rel="stylesheet" type="text/css" href="css/style2.css" />
<script type="text/javascript" src="js/modernizr.custom.04022.js"></script>
<!--[if lt IE 8]>
<style>
.af-wrapper{display:none;}
.ie-note{display:block;}
</style>
<![endif]-->
</head>
<body>
<div class="container">
<!-- Codrops top bar -->
<div class="codrops-top">
<a href="http://tympanus.net/Tutorials/CSS3FluidParallaxSlideshow/">
<strong>« Previous Demo: </strong>Fluid CSS3 Slideshow with Parallax Effect
</a>
<span class="right">
<a href="http://tympanus.net/codrops/2012/05/02/enhance-required-form-fields-with-css3/">
<strong>Back to the Codrops Article</strong>
</a>
</span>
<div class="clr"></div>
</div><!--/ Codrops top bar -->
<header>
<span>Tips & Tricks</span>
<h1>Enhance Required Form Fields <span>with CSS3</span></h1>
<nav class="codrops-demos">
<a href="index.html">Color</a>
<a class="current-demo" href="index2.html">Hide (scale)</a>
<a href="index3.html">3D</a>
</nav>
<p>Click on the button to enhance required fields or de-emphasize/hide optional ones.</p>
<p class="ie-note">D'oh!</p>
</header>
<section class="af-wrapper">
<h3>Random Form</h3>
<input id="af-showreq" class="af-show-input" type="checkbox" name="showreq" />
<label for="af-showreq" class="af-show">Show only required fields</label>
<form class="af-form" id="af-form" novalidate>
<div class="af-outer">
<div class="af-inner">
<label for="input-title">Title</label>
<input type="text" name="title" id="input-title">
</div>
</div>
<div class="af-outer af-required">
<div class="af-inner">
<label for="input-name">Name</label>
<input type="text" name="fullname" id="input-name" required>
</div>
</div>
<div class="af-outer af-required">
<div class="af-inner">
<label for="input-email">Email address</label>
<input type="email" name="email_address" id="input-email" required>
</div>
</div>
<div class="af-outer">
<div class="af-inner">
<label for="input-bdate">Birth Date</label>
<input type="date" name="birthdate" id="input-bdate" placeholder="MM/DD/YYYY">
</div>
</div>
<div class="af-outer af-required">
<div class="af-inner">
<label for="input-country">Country</label>
<input type="email" name="country" id="input-country" required>
</div>
</div>
<div class="af-outer">
<div class="af-inner">
<label for="input-catname">Your cat's name</label>
<input type="email" name="catsname" id="input-catname">
</div>
</div>
<div class="af-outer">
<div class="af-inner">
<label for="input-phone">Phone Number</label>
<input type="email" name="phonenumber" id="input-phone">
</div>
</div>
<input type="submit" value="Send it over!" />
</form>
</section>
</div>
</body>
</html>
JS代码(modernizr.custom.04022.js):
/* Modernizr 2.5.3 (Custom Build) | MIT & BSD * Build:http://www.modernizr.com/download/#-shiv-cssclasses-load */
;
window.Modernizr=function(a,b,c){
function u(a){
j.cssText=a}
function v(a,b){
return u(prefixes.join(a+";
")+(b||""))}
function w(a,b){
return typeof a===b}
function x(a,b){
return!!~(""+a).indexOf(b)}
function y(a,b,d){
for(var e in a){
var f=b[a[e]];
if(f!==c)return d===!1?a[e]:w(f,"function")?f.bind(d||b):f}
return!1}
var d="2.5.3",e={
}
,f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k,l={
}
.toString,m={
}
,n={
}
,o={
}
,p=[],q=p.slice,r,s={
}
.hasOwnProperty,t;
!w(s,"undefined")&&!w(s.call,"undefined")?t=function(a,b){
return s.call(a,b)}
:t=function(a,b){
return b in a&&w(a.constructor.prototype[b],"undefined")}
,Function.prototype.bind||(Function.prototype.bind=function(b){
var c=this;
if(typeof c!="function")throw new TypeError;
var d=q.call(arguments,1),e=function(){
if(this instanceof e){
var a=function(){
}
;
a.prototype=c.prototype;
var f=new a,g=c.apply(f,d.concat(q.call(arguments)));
return Object(g)===g?g:f}
return c.apply(b,d.concat(q.call(arguments)))}
;
return e}
);
for(var z in m)t(m,z)&&(r=z.toLowerCase(),e[r]=m[z](),p.push((e[r]?"":"no-")+r));
return u(""),i=k=null,function(a,b){
function g(a,b){
var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;
return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}
function h(){
var a=k.elements;
return typeof a=="string"?a.split(" "):a}
function i(a){
var b={
}
,c=a.createElement,e=a.createDocumentFragment,f=e();
a.createElement=function(a){
var e=(b[a]||(b[a]=c(a))).cloneNode();
return k.shivMethods&&e.canHaveChildren&&!d.test(a)?f.appendChild(e):e}
,a.createDocumentFragment=Function("h,f","return function(){
var n=f.cloneNode(),c=n.createElement;
h.shivMethods&&("+h().join().replace(/\w+/g,function(a){
return b[a]=c(a),f.createElement(a),'c("'+a+'")'}
)+");
return n}
")(k,f)}
function j(a){
var b;
return a.documentShived?a:(k.shivCSS&&!e&&(b=!!g(a,"article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{
display:block}
audio{
display:none}
canvas,video{
display:inline-block;
*display:inline;
*zoom:1}
[hidden]{
display:none}
audio[controls]{
display:inline-block;
*display:inline;
*zoom:1}
mark{
background:#FF0;
color:#000}
")),f||(b=!i(a)),b&&(a.documentShived=b),a)}
var c=a.html5||{
}
,d=/^<|^(?:button|form|map|select|textarea)$/i,e,f;
(function(){
var a=b.createElement("a");
a.innerHTML="<xyz></xyz>",e="hidden"in a,f=a.childNodes.length==1||function(){
try{
b.createElement("a")}
catch(a){
return!0}
var c=b.createDocumentFragment();
return typeof c.cloneNode=="undefined"||typeof c.createDocumentFragment=="undefined"||typeof c.createElement=="undefined"}
()}
)();
var k={
elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:j}
;
a.html5=k,j(b)}
(this,b),e._version=d,g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+p.join(" "):""),e}
(this,this.document),function(a,b,c){
function d(a){
return o.call(a)=="[object Function]"}
function e(a){
return typeof a=="string"}
function f(){
}
function g(a){
return!a||a=="loaded"||a=="complete"||a=="uninitialized"}
function h(){
var a=p.shift();
q=1,a?a.t?m(function(){
(a.t=="c"?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)}
,0):(a(),h()):q=0}
function i(a,c,d,e,f,i,j){
function k(b){
if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){
a!="img"&&m(function(){
t.removeChild(l)}
,50);
for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}
}
var j=j||B.errorTimeout,l={
}
,o=0,r=0,u={
t:d,s:c,e:f,a:i,x:j}
;
y[c]===1&&(r=1,y[c]=[],l=b.createElement(a)),a=="object"?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){
k.call(this,r)}
,p.splice(e,0,u),a!="img"&&(r||y[c]===2?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}
function j(a,b,c,d,f){
return q=0,b=b||"j",e(a)?i(b=="c"?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),p.length==1&&h()),this}
function k(){
var a=B;
return a.loader={
load:j,i:0}
,a}
var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={
}
.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&o.call(a.opera)=="[object Opera]",l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){
return o.call(a)=="[object Array]"}
,x=[],y={
}
,z={
timeout:function(a,b){
return b.length&&(a.timeout=b[0]),a}
}
,A,B;
B=function(a){
function b(a){
var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={
url:c,origUrl:c,prefixes:a}
,e,f,g;
for(f=0;
f<d;
f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));
for(f=0;
f<b;
f++)c=x[f](c);
return c}
function g(a,e,f,g,i){
var j=b(a),l=j.autoCallback;
j.url.split(".").pop().split("?").shift(),j.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]||h),j.instead?j.instead(a,e,f,g,i):(y[j.url]?j.noexec=!0:y[j.url]=1,f.load(j.url,j.forceCSS||!j.forceJS&&"css"==j.url.split(".").pop().split("?").shift()?"c":c,j.noexec,j.attrs,j.timeout),(d(e)||d(l))&&f.load(function(){
k(),e&&e(j.origUrl,i,g),l&&l(j.origUrl,i,g),y[j.url]=2}
)))}
function i(a,b){
function c(a,c){
if(a){
if(e(a))c||(j=function(){
var a=[].slice.call(arguments);
k.apply(this,a),l()}
),g(a,j,b,0,h);
else if(Object(a)===a)for(n in m=function(){
var b=0,c;
for(c in a)a.hasOwnProperty(c)&&b++;
return b}
(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){
var a=[].slice.call(arguments);
k.apply(this,a),l()}
:j[n]=function(a){
return function(){
var b=[].slice.call(arguments);
a&&a.apply(this,b),l()}
}
(k[n])),g(a[n],j,b,n,h))}
else!c&&l()}
var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;
c(h?a.yep:a.nope,!!i),i&&c(i)}
var j,l,m=this.yepnope.loader;
if(e(a))g(a,0,m,0);
else if(w(a))for(j=0;
j<a.length;
j++)l=a[j],e(l)?g(l,0,m,0):w(l)?B(l):Object(l)===l&&i(l,m);
else Object(a)===a&&i(a,m)}
,B.addPrefix=function(a,b){
z[a]=b}
,B.addFilter=function(a){
x.push(a)}
,B.errorTimeout=1e4,b.readyState==null&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){
b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"}
,0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){
var k=b.createElement("script"),l,o,e=e||B.errorTimeout;
k.src=a;
for(o in d)k.setAttribute(o,d[o]);
c=j?h:c||f,k.onreadystatechange=k.onload=function(){
!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)}
,m(function(){
l||(l=1,c(1))}
,e),i?k.onload():n.parentNode.insertBefore(k,n)}
,a.yepnope.injectCss=function(a,c,d,e,g,i){
var e=b.createElement("link"),j,c=i?h:c||f;
e.href=a,e.rel="stylesheet",e.type="text/css";
for(j in d)e.setAttribute(j,d[j]);
g||(n.parentNode.insertBefore(e,n),m(c,0))}
}
(this,document),Modernizr.load=function(){
yepnope.apply(window,[].slice.call(arguments,0))}
;
CSS代码(demo.css):
@import url('normalize.css');/* General Demo Style */
body{font-family:Cambria,Palatino,"Palatino Linotype","Palatino LT STD",Georgia,serif;background:#fff url(../images/bg.jpg) repeat top left;font-weight:400;font-size:15px;color:#333;-webkit-font-smoothing:antialiased;-moz-font-smoothing:antialiased;font-smoothing:antialiased;}
a{color:#555;text-decoration:none;}
.clr{clear:both;padding:0;height:0;margin:0;}
.container{width:100%;position:relative;min-height:750px;}
.container > header{margin:10px;padding:20px 10px 10px 10px;position:relative;display:block;text-shadow:1px 1px 1px rgba(0,0,0,0.2);text-align:center;}
.container > header > span{font-size:20px;line-height:20px;display:block;font-weight:400;font-style:italic;color:#719dab;text-shadow:1px 1px 1px rgba(0,0,0,0.1);}
.container > header h1{font-size:40px;line-height:40px;margin:0;position:relative;font-weight:300;color:#498ea5;padding:5px 0px;text-shadow:1px 1px 1px rgba(255,255,255,0.7);}
.container > header h1 span{font-weight:700;}
.container > header h2{font-size:14px;font-weight:300;letter-spacing:2px;text-transform:uppercase;margin:0;padding:15px 0 5px 0;color:#6190ca;text-shadow:1px 1px 1px rgba(255,255,255,0.7);}
.container > header p{font-style:italic;color:#aaa;text-shadow:1px 1px 1px rgba(255,255,255,0.7);}
/* Header Style */
.codrops-top{line-height:24px;font-size:11px;background:#fff;background:rgba(255,255,255,0.6);text-transform:uppercase;z-index:9999;position:relative;font-family:Cambria,Georgia,serif;box-shadow:1px 0px 2px rgba(0,0,0,0.2);}
.codrops-top a{padding:0px 10px;letter-spacing:1px;color:#888;display:inline-block;text-shadow:1px 0 0 rgba(255,255,255,0.9);}
.codrops-top a:hover{background:rgba(255,255,255,0.7);}
.codrops-top span.right{float:right;}
.codrops-top span.right a{float:left;display:block;}
/* Demo Buttons Style */
.codrops-demos{text-align:center;display:block;line-height:20px;padding:5px 0px;}
.codrops-demos a{border:1px solid #EF9309;text-shadow:0px 1px 1px rgba();color:#fff;display:inline-block;margin:0 2px;border-radius:4px;padding:2px 15px;font-family:Cambria,Palatino,"Palatino Linotype","Palatino LT STD",Georgia,serif;;font-weight:bold;font-size:13px;background:#ffaf4b;background:-moz-linear-gradient(top,#ffaf4b 0%,#ff920a 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#ffaf4b),color-stop(100%,#ff920a));background:-webkit-linear-gradient(top,#ffaf4b 0%,#ff920a 100%);background:-o-linear-gradient(top,#ffaf4b 0%,#ff920a 100%);background:-ms-linear-gradient(top,#ffaf4b 0%,#ff920a 100%);background:linear-gradient(top,#ffaf4b 0%,#ff920a 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffaf4b',endColorstr='#ff920a',GradientType=0 );box-shadow:0px 1px 2px rgba(0,0,0,0.2);}
.codrops-demos a:hover{box-shadow:0px 1px 1px rgba(255,255,255,0.5);}
.codrops-demos a:active{color:#724C04;text-shadow:0px 1px 1px rgba(255,255,255,0.4);}
.codrops-demos a.current-demo,.codrops-demos a.current-demo:hover,.codrops-demos a.current-demo:active{background:#EF770E;box-shadow:0px 1px 1px rgba(255,255,255,0.5);}
.ie-note{font-size:100px;display:none;}
CSS代码(normalize.css):
/*! normalize.css 2012-03-11T12:53 UTC - http://github.com/necolas/normalize.css */
/* ============================================================================= HTML5 display definitions ========================================================================== */
/* * Corrects block display not defined in IE6/7/8/9 & FF3 */
article,aside,details,figcaption,figure,footer,header,hgroup,nav,section,summary{display:block;}
/* * Corrects inline-block display not defined in IE6/7/8/9 & FF3 */
audio,canvas,video{display:inline-block;*display:inline;*zoom:1;}
/* * Prevents modern browsers from displaying 'audio' without controls * Remove excess height in iOS5 devices */
audio:not([controls]){display:none;height:0;}
/* * Addresses styling for 'hidden' attribute not present in IE7/8/9,FF3,S4 * Known issue:no IE6 support */
[hidden]{display:none;}
/* ============================================================================= Base ========================================================================== */
/* * 1. Corrects text resizing oddly in IE6/7 when body font-size is set using em units * http://clagnut.com/blog/348/#c790 * 2. Prevents iOS text size adjust after orientation change,without disabling user zoom * www.456bereastreet.com/archive/201012/controlling_text_size_in_safari_for_ios_without_disabling_user_zoom/ */
html{font-size:100%;/* 1 */
-webkit-text-size-adjust:100%;/* 2 */
-ms-text-size-adjust:100%;/* 2 */
}
/* * Addresses font-family inconsistency between 'textarea' and other form elements. */
html,button,input,select,textarea{font-family:sans-serif;}
/* * Addresses margins handled incorrectly in IE6/7 */
body{margin:0;}
/* ============================================================================= Links ========================================================================== */
/* * Addresses outline displayed oddly in Chrome */
a:focus{outline:thin dotted;}
/* * Improves readability when focused and also mouse hovered in all browsers * people.opera.com/patrickl/experiments/keyboard/test */
a:hover,a:active{outline:0;}
/* ============================================================================= Typography ========================================================================== */
/* * Addresses font sizes and margins set differently in IE6/7 * Addresses font sizes within 'section' and 'article' in FF4+,Chrome,S5 */
h1{font-size:2em;margin:0.67em 0;}
h2{font-size:1.5em;margin:0.83em 0;}
h3{font-size:1.17em;margin:1em 0;}
h4{font-size:1em;margin:1.33em 0;}
h5{font-size:0.83em;margin:1.67em 0;}
h6{font-size:0.75em;margin:2.33em 0;}
/* * Addresses styling not present in IE7/8/9,S5,Chrome */
abbr[title]{border-bottom:1px dotted;}
/* * Addresses style set to 'bolder' in FF3+,S4/5,Chrome*/
b,strong{font-weight:bold;}
blockquote{margin:1em 40px;}
/* * Addresses styling not present in S5,Chrome */
dfn{font-style:italic;}
/* * Addresses styling not present in IE6/7/8/9 */
mark{background:#ff0;color:#000;}
/* * Addresses margins set differently in IE6/7 */
p,pre{margin:1em 0;}
/* * Corrects font family set oddly in IE6,S4/5,Chrome * en.wikipedia.org/wiki/User:Davidgothberg/Test59 */
pre,code,kbd,samp{font-family:monospace,serif;_font-family:'courier new',monospace;font-size:1em;}
/* * Improves readability of pre-formatted text in all browsers */
pre{white-space:pre;white-space:pre-wrap;word-wrap:break-word;}
/* * 1. Addresses CSS quotes not supported in IE6/7 * 2. Addresses quote property not supported in S4 */
/* 1 */
q{quotes:none;}
/* 2 */
q:before,q:after{content:'';content:none;}
small{font-size:75%;}
/* * Prevents sub and sup affecting line-height in all browsers * gist.github.com/413930 */
sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline;}
sup{top:-0.5em;}
sub{bottom:-0.25em;}
/* ============================================================================= Lists ========================================================================== */
/* * Addresses margins set differently in IE6/7 */
dl,menu,ol,ul{margin:1em 0;}
dd{margin:0 0 0 40px;}
/* * Addresses paddings set differently in IE6/7 */
menu,ol,ul{padding:0 0 0 40px;}
/* * Corrects list images handled incorrectly in IE7 */
nav ul,nav ol{list-style:none;list-style-image:none;}
/* ============================================================================= Embedded content ========================================================================== */
/* * 1. Removes border when inside 'a' element in IE6/7/8/9,FF3 * 2. Improves image quality when scaled in IE7 * code.flickr.com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/ */
img{border:0;/* 1 */
-ms-interpolation-mode:bicubic;/* 2 */
}
/* * Corrects overflow displayed oddly in IE9 */
svg:not(:root){overflow:hidden;}
/* ============================================================================= Figures ========================================================================== */
/* * Addresses margin not present in IE6/7/8/9,S5,O11 */
figure{margin:0;}
/* ============================================================================= Forms ========================================================================== */
/* * Corrects margin displayed oddly in IE6/7 */
form{margin:0;}
/* * Define consistent border,margin,and padding */
fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em;}
/* * 1. Corrects color not being inherited in IE6/7/8/9 * 2. Corrects text not wrapping in FF3 * 3. Corrects alignment displayed oddly in IE6/7 */
legend{border:0;/* 1 */
padding:0;white-space:normal;/* 2 */
*margin-left:-7px;/* 3 */
}
/* * 1. Corrects font size not being inherited in all browsers * 2. Addresses margins set differently in IE6/7,FF3+,S5,Chrome * 3. Improves appearance and consistency in all browsers */
button,input,select,textarea{font-size:100%;/* 1 */
margin:0;/* 2 */
vertical-align:baseline;/* 3 */
*vertical-align:middle;/* 3 */
}
/* * Addresses FF3/4 setting line-height on 'input' using !important in the UA stylesheet */
button,input{line-height:normal;/* 1 */
}
/* * 1. Improves usability and consistency of cursor style between image-type 'input' and others * 2. Corrects inability to style clickable 'input' types in iOS * 3. Removes inner spacing in IE7 without affecting normal text inputs * Known issue:inner spacing remains in IE6 */
button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;/* 1 */
-webkit-appearance:button;/* 2 */
*overflow:visible;/* 3 */
}
/* * Re-set default cursor for disabled elements */
button[disabled],input[disabled]{cursor:default;}
/* * 1. Addresses box sizing set to content-box in IE8/9 * 2. Removes excess padding in IE8/9 * 3. Removes excess padding in IE7 Known issue:excess padding remains in IE6 */
input[type="checkbox"],input[type="radio"]{box-sizing:border-box;/* 1 */
padding:0;/* 2 */
*height:13px;/* 3 */
*width:13px;/* 3 */
}
/* * 1. Addresses appearance set to searchfield in S5,Chrome * 2. Addresses box-sizing set to border-box in S5,Chrome (include -moz to future-proof) */
input[type="search"]{-webkit-appearance:textfield;/* 1 */
-moz-box-sizing:content-box;-webkit-box-sizing:content-box;/* 2 */
box-sizing:content-box;}
/* * Removes inner padding and search cancel button in S5,Chrome on OS X */
input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none;}
/* * Removes inner padding and border in FF3+ * www.sitepen.com/blog/2008/05/14/the-devils-in-the-details-fixing-dojos-toolbar-buttons/ */
button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0;}
/* * 1. Removes default vertical scrollbar in IE6/7/8/9 * 2. Improves readability and alignment in all browsers */
textarea{overflow:auto;/* 1 */
vertical-align:top;/* 2 */
}
/* ============================================================================= Tables ========================================================================== */
/* * Remove most spacing between table cells */
table{border-collapse:collapse;border-spacing:0;}
/* Addition */
/* apply a natural box layout model to all elements */
/* By Paul Irish:http://paulirish.com/2012/box-sizing-border-box-ftw/ */
*{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;}
CSS代码(style.css):
.af-wrapper{width:94%;max-width:700px;min-width:280px;margin:0 auto 30px auto;background:#fff url(../images/try.jpg) no-repeat 99% 30px;position:relative;padding:20px;box-shadow:1px 2px 4px rgba(0,0,0,0.2);}
.af-wrapper h3{margin:0px;color:#444;padding:10px;}
.af-show{position:absolute;top:30px;right:155px;cursor:pointer;padding:3px 0px;width:190px;text-align:center;font-weight:bold;border:1px solid #A8BC65;color:#6d7649;border-radius:4px;background:#e4efc0;text-shadow:0px 1px 1px rgba(255,255,255,0.4);background:#cae082;background:-moz-linear-gradient(top,#cae082 0%,#abbd73 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#cae082),color-stop(100%,#abbd73));background:-webkit-linear-gradient(top,#cae082 0%,#abbd73 100%);background:-o-linear-gradient(top,#cae082 0%,#abbd73 100%);background:-ms-linear-gradient(top,#cae082 0%,#abbd73 100%);background:linear-gradient(top,#cae082 0%,#abbd73 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#cae082',endColorstr='#abbd73',GradientType=0 );box-shadow:0 1px 2px rgba(0,0,0,0.2);}
.af-show:hover{color:#535B31;}
.af-show-input{position:absolute;top:20px;right:20px;cursor:pointer;width:190px;height:24px;opacity:0;}
.af-show-input:checked ~ .af-show{background:#cae082;color:#535B31;box-shadow:0 1px 2px rgba(255,255,255,0.6);}
.af-form{padding:10px 0px;}
.af-form:before,.af-form:after{content:"";display:table;}
.af-form:after{clear:both;}
.af-outer{box-shadow:0 1px 0 #f5f5f5 inset;-webkit-transition:all 0.5s linear;-moz-transition:all 0.5s linear;-o-transition:all 0.5s linear;-ms-transition:all 0.5s linear;transition:all 0.5s linear;}
.af-inner{padding:15px 20px 15px 20px;-webkit-transition:all 0.5s linear;-moz-transition:all 0.5s linear;-o-transition:all 0.5s linear;-ms-transition:all 0.5s linear;transition:all 0.5s linear;}
#af-showreq:checked ~ .af-form .af-outer.af-required{background:#fffde3;}
#af-showreq:checked ~ .af-form .af-outer:not(.af-required) .af-inner{opacity:0.4;}
.af-form label{display:block;display:-webkit-box;display:-moz-box;display:box;-moz-box-orient:horizontal;-moz-box-pack:end;-moz-box-align:center;-webkit-box-orient:horizontal;-webkit-box-pack:end;-webkit-box-align:center;box-orient:horizontal;box-pack:end;box-align:center;height:40px;float:left;padding-right:3%;width:30%;min-width:80px;font-size:13px;color:#888;letter-spacing:3px;text-transform:uppercase;text-align:right;text-shadow:1px 1px 1px rgba(255,255,255,0.6);}
.af-form .af-required label{color:#555;}
.af-form input[type=text],.af-form input[type=email],.af-form input[type=date]{border:1px solid #ddd;padding:10px;font-weight:bold;text-shadow:0 1px 1px rgba(255,255,255,0.8);color:#666;width:64%;background:#ffffff;background:-moz-linear-gradient(top,#ffffff 0%,#f7f7f7 7%,#f7f7f7 22%,#ffffff 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#ffffff),color-stop(7%,#f7f7f7),color-stop(22%,#f7f7f7),color-stop(100%,#ffffff));background:-webkit-linear-gradient(top,#ffffff 0%,#f7f7f7 7%,#f7f7f7 22%,#ffffff 100%);background:-o-linear-gradient(top,#ffffff 0%,#f7f7f7 7%,#f7f7f7 22%,#ffffff 100%);background:-ms-linear-gradient(top,#ffffff 0%,#f7f7f7 7%,#f7f7f7 22%,#ffffff 100%);background:linear-gradient(top,#ffffff 0%,#f7f7f7 7%,#f7f7f7 22%,#ffffff 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff',endColorstr='#ffffff',GradientType=0 );box-shadow:0px 1px 1px rgba(255,255,255,0.7),1px 1px 2px rgba(0,0,0,0.1) inset;}
.af-form input:focus{background:#f9fcef;outline:none;}
.af-form input[type="submit"]{border:1px solid #EF9309;text-shadow:0px 1px 1px rgba(255,255,255,0.4);color:#724C04;display:inline-block;border-radius:4px;margin-top:10px;margin-left:33%;padding:6px 15px;font-family:Cambria,Palatino,"Palatino Linotype","Palatino LT STD",Georgia,serif;font-weight:bold;background:#ffaf4b;background:-moz-linear-gradient(top,#ffaf4b 0%,#ff920a 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#ffaf4b),color-stop(100%,#ff920a));background:-webkit-linear-gradient(top,#ffaf4b 0%,#ff920a 100%);background:-o-linear-gradient(top,#ffaf4b 0%,#ff920a 100%);background:-ms-linear-gradient(top,#ffaf4b 0%,#ff920a 100%);background:linear-gradient(top,#ffaf4b 0%,#ff920a 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffaf4b',endColorstr='#ff920a',GradientType=0 );box-shadow:0px 1px 2px rgba(0,0,0,0.2);}
.af-form input[type="submit"]:active{box-shadow:0px 1px 2px rgba(255,255,255,0.5);background:#ffaf4b;}
::-webkit-validation-bubble{z-index:100000;}
@media screen and (max-width:780px){.af-wrapper{background-position:220px 60px;}
.af-wrapper h3{padding-bottom:50px;}
.af-show{top:66px;right:auto;left:30px;}
}
@media screen and (max-width:385px){.af-wrapper{background:#fff;}
}
@media screen and (max-width:330px){.af-form label,.af-form input[type=text],.af-form input[type=email],.af-form input[type=date]{width:100%;}
.af-form label{-moz-box-pack:center;-webkit-box-pack:center;box-pack:center;text-align:center;}
}