3 Star 18 Fork 7

杨得朝/web-test

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CSS3表单input输入框美化.html 25.45 KB
一键复制 编辑 原始数据 按行查看 历史
杨得朝 提交于 2020-07-10 18:35 . submit
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
<!DOCTYPE html>
<html lang="zh" class="no-js">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>表单input输入框</title>
<style>
article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary {
display: block;
}
audio, canvas, video {
display: inline-block;
}
audio:not([controls]) {
display: none;
height: 0;
}
[hidden] {
display: none;
}
html {
font-family: sans-serif;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
}
a:focus {
outline: thin dotted;
}
a:active, a:hover {
outline: 0;
}
h1 {
font-size: 2em;
margin: 0.67em 0;
}
abbr[title] {
border-bottom: 1px dotted;
}
b, strong {
font-weight: bold;
}
dfn {
font-style: italic;
}
hr {
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 0;
}
mark {
background: #ff0;
color: #000;
}
code, kbd, pre, samp {
font-family: monospace, serif;
font-size: 1em;
}
pre {
white-space: pre-wrap;
}
q {
quotes: "\201C" "\201D" "\2018" "\2019";
}
small {
font-size: 80%;
}
sub, sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
img {
border: 0;
}
svg:not(:root) {
overflow: hidden;
}
figure {
margin: 0;
}
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
legend {
border: 0;
padding: 0;
}
button, input, select, textarea {
font-family: inherit;
font-size: 100%;
margin: 0;
}
button, input {
line-height: normal;
}
button, select {
text-transform: none;
}
button, html input[type="button"], input[type="reset"], input[type="submit"] {
-webkit-appearance: button;
cursor: pointer;
}
button[disabled], html input[disabled] {
cursor: default;
}
input[type="checkbox"], input[type="radio"] {
box-sizing: border-box;
padding: 0;
}
input[type="search"] {
-webkit-appearance: textfield;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
button::-moz-focus-inner, input::-moz-focus-inner {
border: 0;
padding: 0;
}
textarea {
overflow: auto;
vertical-align: top;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
@import url(http://fonts.useso.com/css?family=Raleway:200,500,700,800);
@font-face {
font-weight: normal;
font-style: normal;
font-family: 'codropsicons';
src: url('../fonts/codropsicons/codropsicons.eot');
src: url('../fonts/codropsicons/codropsicons.eot?#iefix') format('embedded-opentype'),
url('../fonts/codropsicons/codropsicons.woff') format('woff'),
url('../fonts/codropsicons/codropsicons.ttf') format('truetype'),
url('../fonts/codropsicons/codropsicons.svg#codropsicons') format('svg');
}
*, *:after, *:before {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.clearfix:before, .clearfix:after {
content: '';
display: table;
}
.clearfix:after {
clear: both;
}
body {
background: #f9f7f6;
color: #404d5b;
font-weight: 500;
font-size: 1.05em;
font-family: 'Raleway', Arial, sans-serif;
}
a {
color: #2fa0ec;
text-decoration: none;
outline: none;
}
a:hover, a:focus {
color: #74777b;
}
.container {
margin: 0 auto;
text-align: center;
overflow: hidden;
}
.content {
font-size: 150%;
padding: 3em 0;
}
.content h2 {
margin: 0 0 2em;
opacity: 0.1;
}
.content p {
margin: 1em 0;
padding: 5em 0 0 0;
font-size: 0.65em;
}
.bgcolor-1 {
background: #f0efee;
}
.bgcolor-2 {
background: #f9f9f9;
}
.bgcolor-3 {
background: #e8e8e8;
}
.bgcolor-4 {
background: #2f3238;
color: #fff;
}
.bgcolor-5 {
background: #df6659;
color: #521e18;
}
.bgcolor-6 {
background: #2fa8ec;
}
.bgcolor-7 {
background: #d0d6d6;
}
.bgcolor-8 {
background: #3d4444;
color: #fff;
}
body .nomargin-bottom {
margin-bottom: 0;
}
/* Header */
.codrops-header {
padding: 3em 190px 4em;
letter-spacing: -1px;
}
.codrops-header h1 {
font-weight: 800;
font-size: 4em;
line-height: 1;
margin-bottom: 0;
}
.codrops-header h1 span {
display: block;
font-size: 50%;
font-weight: 400;
padding: 0.325em 0 0.5em 0;
color: #c3c8cd;
}
/* Top Navigation Style */
.codrops-links {
position: relative;
display: inline-block;
white-space: nowrap;
font-size: 1.25em;
text-align: center;
}
.codrops-links::after {
position: absolute;
top: 0;
left: 50%;
margin-left: -1px;
width: 2px;
height: 100%;
background: #dbdbdb;
content: '';
-webkit-transform: rotate3d(0, 0, 1, 22.5deg);
transform: rotate3d(0, 0, 1, 22.5deg);
}
.codrops-icon {
display: inline-block;
margin: 0.5em;
padding: 0em 0;
width: 1.5em;
text-decoration: none;
}
.codrops-icon span {
display: none;
}
.codrops-icon:before {
margin: 0 5px;
text-transform: none;
font-weight: normal;
font-style: normal;
font-variant: normal;
font-family: 'codropsicons';
line-height: 1;
speak: none;
-webkit-font-smoothing: antialiased;
}
.codrops-icon--drop:before {
content: "\e001";
}
.codrops-icon--prev:before {
content: "\e004";
}
/* Related demos */
.content--related {
text-align: center;
color: #D8DADB;
font-weight: bold;
}
.media-item {
display: inline-block;
padding: 1em;
vertical-align: top;
-webkit-transition: color 0.3s;
transition: color 0.3s;
}
.media-item__img {
opacity: 0.8;
-webkit-transition: opacity 0.3s;
transition: opacity 0.3s;
}
.media-item:hover .media-item__img,
.media-item:focus .media-item__img {
opacity: 1;
}
.media-item__title {
font-size: 0.75em;
margin: 0;
padding: 0.5em;
}
@media screen and (max-width: 50em) {
.codrops-header {
padding: 3em 10% 4em;
}
}
@media screen and (max-width: 40em) {
.codrops-header h1 {
font-size: 2.8em;
}
}
article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary {
display: block;
}
audio, canvas, video {
display: inline-block;
}
audio:not([controls]) {
display: none;
height: 0;
}
[hidden] {
display: none;
}
html {
font-family: sans-serif;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
}
a:focus {
outline: thin dotted;
}
a:active, a:hover {
outline: 0;
}
h1 {
font-size: 2em;
margin: 0.67em 0;
}
abbr[title] {
border-bottom: 1px dotted;
}
b, strong {
font-weight: bold;
}
dfn {
font-style: italic;
}
hr {
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 0;
}
mark {
background: #ff0;
color: #000;
}
code, kbd, pre, samp {
font-family: monospace, serif;
font-size: 1em;
}
pre {
white-space: pre-wrap;
}
q {
quotes: "\201C" "\201D" "\2018" "\2019";
}
small {
font-size: 80%;
}
sub, sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
img {
border: 0;
}
svg:not(:root) {
overflow: hidden;
}
figure {
margin: 0;
}
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
legend {
border: 0;
padding: 0;
}
button, input, select, textarea {
font-family: inherit;
font-size: 100%;
margin: 0;
}
button, input {
line-height: normal;
}
button, select {
text-transform: none;
}
button, html input[type="button"], input[type="reset"], input[type="submit"] {
-webkit-appearance: button;
cursor: pointer;
}
button[disabled], html input[disabled] {
cursor: default;
}
input[type="checkbox"], input[type="radio"] {
box-sizing: border-box;
padding: 0;
}
input[type="search"] {
-webkit-appearance: textfield;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
button::-moz-focus-inner, input::-moz-focus-inner {
border: 0;
padding: 0;
}
textarea {
overflow: auto;
vertical-align: top;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
</style>
<!--[if IE]>
<script src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<section class="content bgcolor-1">
<h2 class="nomargin-bottom">Haruki</h2>
<span class="input input--haruki">
<input class="input__field input__field--haruki" type="text" id="input-1" />
<label class="input__label input__label--haruki" for="input-1">
<span class="input__label-content input__label-content--haruki">First Name</span>
</label>
</span>
<span class="input input--haruki">
<input class="input__field input__field--haruki" type="text" id="input-2" />
<label class="input__label input__label--haruki" for="input-2">
<span class="input__label-content input__label-content--haruki">Last Name</span>
</label>
</span>
<span class="input input--haruki">
<input class="input__field input__field--haruki" type="text" id="input-3" />
<label class="input__label input__label--haruki" for="input-3">
<span class="input__label-content input__label-content--haruki">Email</span>
</label>
</span>
</section>
<section class="content">
<h2>Hoshi</h2>
<span class="input input--hoshi">
<input class="input__field input__field--hoshi" type="text" id="input-4" />
<label class="input__label input__label--hoshi input__label--hoshi-color-1" for="input-4">
<span class="input__label-content input__label-content--hoshi">Name</span>
</label>
</span>
<span class="input input--hoshi">
<input class="input__field input__field--hoshi" type="text" id="input-5" />
<label class="input__label input__label--hoshi input__label--hoshi-color-2" for="input-5">
<span class="input__label-content input__label-content--hoshi">Street</span>
</label>
</span>
<span class="input input--hoshi">
<input class="input__field input__field--hoshi" type="text" id="input-6" />
<label class="input__label input__label--hoshi input__label--hoshi-color-3" for="input-6">
<span class="input__label-content input__label-content--hoshi">Town</span>
</label>
</span>
<p>Inspired by Andrej Radisic's <a href="https://dribbble.com/shots/1785176-Jawbreaker-input-field">Jawbreaker
input
field</a></p>
</section>
<section class="content bgcolor-4">
<h2>Kuro</h2>
<span class="input input--kuro">
<input class="input__field input__field--kuro" type="text" id="input-7" />
<label class="input__label input__label--kuro" for="input-7">
<span class="input__label-content input__label-content--kuro">Username</span>
</label>
</span>
<span class="input input--kuro">
<input class="input__field input__field--kuro" type="text" id="input-8" />
<label class="input__label input__label--kuro" for="input-8">
<span class="input__label-content input__label-content--kuro">Website</span>
</label>
</span>
<span class="input input--kuro">
<input class="input__field input__field--kuro" type="text" id="input-9" />
<label class="input__label input__label--kuro" for="input-9">
<span class="input__label-content input__label-content--kuro">Invitation Code</span>
</label>
</span>
</section>
<section class="content bgcolor-7">
<h2>Jiro</h2>
<span class="input input--jiro">
<input class="input__field input__field--jiro" type="text" id="input-10" />
<label class="input__label input__label--jiro" for="input-10">
<span class="input__label-content input__label-content--jiro">Cat's Name</span>
</label>
</span>
<span class="input input--jiro">
<input class="input__field input__field--jiro" type="text" id="input-11" />
<label class="input__label input__label--jiro" for="input-11">
<span class="input__label-content input__label-content--jiro">Dog's Name</span>
</label>
</span>
<span class="input input--jiro">
<input class="input__field input__field--jiro" type="text" id="input-12" />
<label class="input__label input__label--jiro" for="input-12">
<span class="input__label-content input__label-content--jiro">Hamster's Name</span>
</label>
</span>
</section>
<section class="content">
<h2>Minoru</h2>
<span class="input input--minoru">
<input class="input__field input__field--minoru" type="text" id="input-13" />
<label class="input__label input__label--minoru" for="input-13">
<span class="input__label-content input__label-content--minoru">First Name</span>
</label>
</span>
<span class="input input--minoru">
<input class="input__field input__field--minoru" type="text" id="input-14" />
<label class="input__label input__label--minoru" for="input-14">
<span class="input__label-content input__label-content--minoru">Middle Name</span>
</label>
</span>
<span class="input input--minoru">
<input class="input__field input__field--minoru" type="text" id="input-15" />
<label class="input__label input__label--minoru" for="input-15">
<span class="input__label-content input__label-content--minoru">Last Name</span>
</label>
</span>
</section>
<section class="content bgcolor-5">
<h2>Yoko</h2>
<span class="input input--minoru">
<input class="input__field input__field--yoko" type="text" id="input-16" />
<label class="input__label input__label--yoko" for="input-16">
<span class="input__label-content input__label-content--yoko">Street</span>
</label>
</span>
<span class="input input--minoru">
<input class="input__field input__field--yoko" type="text" id="input-17" />
<label class="input__label input__label--yoko" for="input-17">
<span class="input__label-content input__label-content--yoko">City</span>
</label>
</span>
<span class="input input--minoru">
<input class="input__field input__field--yoko" type="text" id="input-18" />
<label class="input__label input__label--yoko" for="input-18">
<span class="input__label-content input__label-content--yoko">Region</span>
</label>
</span>
</section>
<section class="content">
<h2>Hideo</h2>
<span class="input input--hideo">
<input class="input__field input__field--hideo" type="text" id="input-41" />
<label class="input__label input__label--hideo" for="input-41">
<i class="fa fa-fw fa-user icon icon--hideo"></i>
<span class="input__label-content input__label-content--hideo">Username</span>
</label>
</span>
<span class="input input--hideo">
<input class="input__field input__field--hideo" type="text" id="input-42" />
<label class="input__label input__label--hideo" for="input-42">
<i class="fa fa-fw fa-envelope icon icon--hideo"></i>
<span class="input__label-content input__label-content--hideo">Email</span>
</label>
</span>
<span class="input input--hideo">
<input class="input__field input__field--hideo" type="text" id="input-43" />
<label class="input__label input__label--hideo" for="input-43">
<i class="fa fa-fw fa-lock icon icon--hideo"></i>
<span class="input__label-content input__label-content--hideo">Password</span>
</label>
</span>
</section>
<section class="content bgcolor-3">
<h2>Kyo</h2>
<span class="input input--kyo">
<input class="input__field input__field--kyo" type="text" id="input-19" />
<label class="input__label input__label--kyo" for="input-19">
<span class="input__label-content input__label-content--kyo">What's your email?</span>
</label>
</span>
</section>
<section class="content bgcolor-4">
<h2>Akira</h2>
<span class="input input--akira">
<input class="input__field input__field--akira" type="text" id="input-22" />
<label class="input__label input__label--akira" for="input-22">
<span class="input__label-content input__label-content--akira">First Name</span>
</label>
</span>
<span class="input input--akira">
<input class="input__field input__field--akira" type="text" id="input-23" />
<label class="input__label input__label--akira" for="input-23">
<span class="input__label-content input__label-content--akira">Last Name</span>
</label>
</span>
<span class="input input--akira">
<input class="input__field input__field--akira" type="text" id="input-24" />
<label class="input__label input__label--akira" for="input-24">
<span class="input__label-content input__label-content--akira">Maiden Name</span>
</label>
</span>
</section>
<section class="content">
<h2>Ichiro</h2>
<span class="input input--ichiro">
<input class="input__field input__field--ichiro" type="text" id="input-25" />
<label class="input__label input__label--ichiro" for="input-25">
<span class="input__label-content input__label-content--ichiro">Bird's Color</span>
</label>
</span>
<span class="input input--ichiro">
<input class="input__field input__field--ichiro" type="text" id="input-26" />
<label class="input__label input__label--ichiro" for="input-26">
<span class="input__label-content input__label-content--ichiro">Wing Span</span>
</label>
</span>
<span class="input input--ichiro">
<input class="input__field input__field--ichiro" type="text" id="input-27" />
<label class="input__label input__label--ichiro" for="input-27">
<span class="input__label-content input__label-content--ichiro">Beak Length</span>
</label>
</span>
</section>
<section class="content bgcolor-6">
<h2>Juro</h2>
<span class="input input--juro">
<input class="input__field input__field--juro" type="text" id="input-28" />
<label class="input__label input__label--juro" for="input-28">
<span class="input__label-content input__label-content--juro">First Name</span>
</label>
</span>
<span class="input input--juro">
<input class="input__field input__field--juro" type="text" id="input-29" />
<label class="input__label input__label--juro" for="input-29">
<span class="input__label-content input__label-content--juro">Last Name</span>
</label>
</span>
<span class="input input--juro">
<input class="input__field input__field--juro" type="text" id="input-30" />
<label class="input__label input__label--juro" for="input-30">
<span class="input__label-content input__label-content--juro">Maiden Name</span>
</label>
</span>
</section>
<section class="content bgcolor-4">
<h2>Madoka</h2>
<span class="input input--madoka">
<input class="input__field input__field--madoka" type="text" id="input-31" />
<label class="input__label input__label--madoka" for="input-31">
<svg class="graphic graphic--madoka" width="100%" height="100%" viewBox="0 0 404 77" preserveAspectRatio="none">
<path d="m0,0l404,0l0,77l-404,0l0,-77z" />
</svg>
<span class="input__label-content input__label-content--madoka">Frequency</span>
</label>
</span>
<span class="input input--madoka">
<input class="input__field input__field--madoka" type="text" id="input-32" />
<label class="input__label input__label--madoka" for="input-32">
<svg class="graphic graphic--madoka" width="100%" height="100%" viewBox="0 0 404 77" preserveAspectRatio="none">
<path d="m0,0l404,0l0,77l-404,0l0,-77z" />
</svg>
<span class="input__label-content input__label-content--madoka">Weight</span>
</label>
</span>
<span class="input input--madoka">
<input class="input__field input__field--madoka" type="text" id="input-33" />
<label class="input__label input__label--madoka" for="input-33">
<svg class="graphic graphic--madoka" width="100%" height="100%" viewBox="0 0 404 77" preserveAspectRatio="none">
<path d="m0,0l404,0l0,77l-404,0l0,-77z" />
</svg>
<span class="input__label-content input__label-content--madoka">Strength</span>
</label>
</span>
</section>
<section class="content">
<h2>Kaede</h2>
<span class="input input--kaede">
<input class="input__field input__field--kaede" type="text" id="input-35" />
<label class="input__label input__label--kaede" for="input-35">
<span class="input__label-content input__label-content--kaede">First Name</span>
</label>
</span>
<span class="input input--kaede">
<input class="input__field input__field--kaede" type="text" id="input-36" />
<label class="input__label input__label--kaede" for="input-36">
<span class="input__label-content input__label-content--kaede">Last Name</span>
</label>
</span>
<span class="input input--kaede">
<input class="input__field input__field--kaede" type="text" id="input-37" />
<label class="input__label input__label--kaede" for="input-37">
<span class="input__label-content input__label-content--kaede">Website</span>
</label>
</span>
</section>
<section class="content bgcolor-8">
<h2>Isao</h2>
<span class="input input--isao">
<input class="input__field input__field--isao" type="text" id="input-38" />
<label class="input__label input__label--isao" for="input-38" data-content="First Name">
<span class="input__label-content input__label-content--isao">First Name</span>
</label>
</span>
<span class="input input--isao">
<input class="input__field input__field--isao" type="text" id="input-39" />
<label class="input__label input__label--isao" for="input-39" data-content="Middle Name">
<span class="input__label-content input__label-content--isao">Middle Name</span>
</label>
</span>
<span class="input input--isao">
<input class="input__field input__field--isao" type="text" id="input-40" />
<label class="input__label input__label--isao" for="input-40" data-content="Last Name">
<span class="input__label-content input__label-content--isao">Last Name</span>
</label>
</span>
</section>
</div>
<!-- /container -->
<script>
/*!
* classie - class helper functions 封装js
* from bonzo https://github.com/ded/bonzo
*
* classie.has( elem, 'my-class' ) -> true/false
* classie.add( elem, 'my-new-class' )
* classie.remove( elem, 'my-unwanted-class' )
* classie.toggle( elem, 'my-class' )
*/
/*jshint browser: true, strict: true, undef: true */
/*global define: false */
(function(window) {
'use strict';
// class helper functions from bonzo https://github.com/ded/bonzo
function classReg(className) {
return new RegExp("(^|\\s+)" + className + "(\\s+|$)");
}
// classList support for class management
// altho to be fair, the api sucks because it won't accept multiple classes at once
var hasClass, addClass, removeClass;
if ('classList' in document.documentElement) {
hasClass = function(elem, c) {
return elem.classList.contains(c);
};
addClass = function(elem, c) {
elem.classList.add(c);
};
removeClass = function(elem, c) {
elem.classList.remove(c);
};
} else {
hasClass = function(elem, c) {
return classReg(c).test(elem.className);
};
addClass = function(elem, c) {
if (!hasClass(elem, c)) {
elem.className = elem.className + ' ' + c;
}
};
removeClass = function(elem, c) {
elem.className = elem.className.replace(classReg(c), ' ');
};
}
function toggleClass(elem, c) {
var fn = hasClass(elem, c) ? removeClass : addClass;
fn(elem, c);
}
var classie = {
// full names
hasClass: hasClass,
addClass: addClass,
removeClass: removeClass,
toggleClass: toggleClass,
// short names
has: hasClass,
add: addClass,
remove: removeClass,
toggle: toggleClass
};
// transport
if (typeof define === 'function' && define.amd) {
// AMD
define(classie);
} else {
// browser global
window.classie = classie;
}
})(window);
</script>
<script>
(function() {
// trim polyfill : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim
if (!String.prototype.trim) {
(function() {
// Make sure we trim BOM and NBSP
var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
String.prototype.trim = function() {
return this.replace(rtrim, '');
};
})();
}
[].slice.call(document.querySelectorAll('input.input__field')).forEach(function(inputEl) {
// in case the input is already filled..
if (inputEl.value.trim() !== '') {
classie.add(inputEl.parentNode, 'input--filled');
}
// events:
inputEl.addEventListener('focus', onInputFocus);
inputEl.addEventListener('blur', onInputBlur);
});
function onInputFocus(ev) {
classie.add(ev.target.parentNode, 'input--filled');
}
function onInputBlur(ev) {
if (ev.target.value.trim() === '') {
classie.remove(ev.target.parentNode, 'input--filled');
}
}
})();
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/yangdechao_admin/web-test.git
git@gitee.com:yangdechao_admin/web-test.git
yangdechao_admin
web-test
web-test
master

搜索帮助