JS development verification form tutorial style (2)
Let’s take a look at the code in the previous section:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{margin:0;padding:0;}
#div{width:410px;height:400px;background:#46a3ff;padding-left:16px;
padding-top:20px;}
.name{width:200px;height:30px;margin-left:8px;border:1px solid #ffc1e0;}
.pwd{width:200px;height:30px;margin-left:8px;border:1px solid #ffc1e0;}
.email{width:200px;height:30px;margin-left:8px;border:1px solid #ffc1e0;}
.txt{width:280px;height:70px;margin-left:8px;border:1px solid #ffc1e0;}
.sub{width:100px;height:30px;padding-left:0px;}
.sub:hover{background:#ffaad5;}
.div{width:200px;height:30px;margin:0 auto;padding-left:45px;padding-top:5px;color:#8600ff;font-weight:bold;
border:1px solid red;}
</style>
</style>
</head>
<body>
<div id="div">
<form>
<label>用户名:</label>
<input type="text" class="name" id="name">
<div id="sp" class="div"></div>
<label>密 码:</label>
<input type="password" class="pwd" id="pwd">
<div id="sp1" class="div"></div>
<label>邮 箱:</label>
<input type="text" class="email" id="email">
<div id="sp2" class="div"></div>
<label>爱 好:</label>
<textarea rows="5" cols="40" class="txt" id="txt"></textarea>
<div id="sp3" class="div"></div>
<input type="button" class="sub" value="注册" id="sub">
</form>
</div>
</body>
</html>First we remove the default style of the input box
outline attribute
The complete code is as follows:
input{outline:none;}
When we put the cursor in the input box, it will be very far to the left, which does not look good, so we need to position the cursor a certain distance from the left Distance
Generally we use padding-left, but there is a problem. After using it, the text box also becomes longer, which is not the effect we want
So when we add text When adding the padding-left attribute to the cursor of the box, we must first write box-sizing:border-box;
box-sizing:border-box; The inner margin and outer border of the element will not increase the width
So the complete code for the style of our text box is as follows:
input{
outline:none;/*Remove the border of the text box*
box-sizing:border-box; padding-left:15px;
}
Of course the text field can also be used
Next we will make a rounded corner function for the text field
border-radius:8px;
By default, the text field has two slashes in the lower corner, which we can also remove.
We use resize: none; for the text field Remove the slash
Let’s look at the following complete code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{margin:0;padding:0;}
#div{width:410px;height:400px;background:#46a3ff;padding-left:16px;
padding-top:20px;}
input{
outline:none;
box-sizing:border-box;padding-left:15px;}
textarea{
outline:none;resize : none;
box-sizing:border-box;padding-left:15px;padding-top:5px;}
.name{width:200px;height:30px;margin-left:8px;border:1px solid #ffc1e0;border-radius:8px;}
.pwd{width:200px;height:30px;
margin-left:8px;border:1px solid #ffc1e0;border-radius:8px;}
.email{width:200px;height:30px;margin-left:8px;border:1px solid #ffc1e0;border-radius:8px;}
.txt{
width:280px;height:70px;margin-left:8px;border:1px solid #ffc1e0;border-radius:8px;}
.sub{width:100px;height:30px;padding-left:0px;
border:none;
border-radius:5px;background:#ffd0ff;}
.sub:hover{background:#ffaad5;}
.div{
width:200px;height:30px;margin:0 auto;box-sizing:border-box;padding-left:45px;padding-top:5px;color:#8600ff;font-weight:bold;}
</style>
</head>
<body>
<div id="div">
<form>
<label>用户名:</label>
<input type="text" class="name" id="name">
<div id="sp" class="div"></div>
<label>密 码:</label>
<input type="password" class="pwd" id="pwd">
<div id="sp1" class="div"></div>
<label>邮 箱:</label>
<input type="text" class="email" id="email">
<div id="sp2" class="div"></div>
<label>爱 好:</label>
<textarea rows="5" cols="40" class="txt" id="txt"></textarea>
<div id="sp3" class="div"></div>
<input type="button" class="sub" value="注册" id="sub">
</form>
</div>
</body>
</html> 

