Form input box focus highlight css code

With the popularity of HTML 5 + CSS 3, the page effects we use CSS code to achieve are more and more gorgeous, and the highlight effect when the form input box gets the focus is a must-have form nirvana for many HTML 5 sites. Especially after Twitter launched the Bootstrap framework, the form highlight effect has almost become a necessity for Bootstrap.

Now, let's write the following css code to imitate Bootstrap's form focus highlight effect.

 

Name:
<input type="text" />
<br/>
age:
<input type="text" />

 

input, textarea {
	box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
	transition: border linear 0.2s, box-shadow linear 0.2s;
}
input, textarea, select {
	font-size: 1em;
	display: inline-block;
	padding: 4px;
	color: #555555;
	vertical-align: middle;
	background-color: #ffffff;
	border: 1px solid #cccccc;
	border-radius: 3px;
	margin: 3px 0;
}
/* The input box highlight effect when the focus is obtained*/
input:focus,
textarea:focus {
	border-color: rgba(82, 168, 236, 0.8);
	outline: 0;
	outline: thin dotted \9;
	/ * IE6-9 * /  
	box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
}
/* Avoid adverse effects on other elements (mainly in IE browsers) */
input[type="file"]:focus,
input[type="radio"]:focus,
input[type="checkbox"]:focus,
select:focus {
	outline: thin dotted #333;
	outline: 5px auto -webkit-focus-ring-color;
	outline-offset: -2px;
	box-shadow: none;
}
input[type="image"],
input[type="checkbox"],
input[type="radio"] {
	padding: 0;
	margin: 3px 0;
	*margin-top: 0;
	/* IE7 */
	line-height: normal;
	cursor: pointer;
	background-color: transparent;
	border: 0 \9;
	/* IE9- */
	border-radius: 0;
}
/* Avoid bad effects on button styles */
input[type="button"],
input[type="submit"],
.btn {
	display: inline-block;
	*display: inline;
	padding: 4px 10px;
	font-size: 1em;
	color: #333333;
	text-align: center;
	text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
	cursor: pointer;
	background-color: #f5f5f5;
	*background-color: #e6e6e6;
	background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
	background-image: linear-gradient(top, #ffffff, #e6e6e6);
	background-repeat: repeat-x;
	border: 1px solid #cccccc;
	*border: 0;
	border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
	border-color: #e6e6e6 #e6e6e6 #bfbfbf;
	border-bottom-color: #b3b3b3;
	border-radius: 4px;
	filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffffff', endColorstr='#e6e6e6', GradientType=0);
	filter: progid:dximagetransform.microsoft.gradient(enabled=false);
	*zoom: 1;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}

 

.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326331544&siteId=291194637