单行文本框
首先在网页中创建一个表单,代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
input:focus, textarea:focus{
border:1px solid #f00;
background: #fcc;
}
</style>
</head>
<body>
<form action="#" method="POST" id="regForm">
<legend>个人基本信息</legend>
<div>
<label for="username">名称:</label>
<input id="username" type="text"></label>
</div>
<div>
<label for="pass">密码:</label>
<input id="pass" type="password"></label>
</div>
<div>
<label for="msg">详细信息:</label>
<textarea id="msg"></textarea>
</div>
</form>
</body>
</html>
但是IE6并不支持除超链接元素之外的:hover伪类选择器,此时可以用jQuery来弥补。