1.表单标签
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<!--form:用于表示采集用户信息的范围
action:指定提交数据的url
method:指定提交方式
*一共有7种2种比较常用
get:1.请求参数会在地址栏中显示,封装到请求行中
2.请求参数大小是有限制的
3.不安全
post:1.请求参数不会在地址栏中显示,会封装在请求体中
2.请求参数的大小没有限制
3.较为安全
表单中的数据想要被提交必须指定其name属性
-->
<!--表单项标签
input:可以通过type属性,改变元素展示的样式
type属性:
text:文本输入框,默认值--placehoder:指定提示的输入信息,输入时自动清空提示信息
password:密码输入
radio:单选框
1.让多个选项实现单选,设置的name值要相同
2.指定value属性,来指定提交的值
3.checked属性可以指定默认的值
checkbox:
1.让多个选项实现多选,设置的name值要相同
2.指定value属性,来指定提交的值
3.checked属性可以指定默认的值
lable:指定输入项的文字描述信息,lable的for属性和input的id相对应,点击标签会跳光标到输入框
-->
<form action="#" method="get">
<label for="username">用户名:</label><input type="text" name="username" placeholder="输入用户名" id="username"><br>
<label for="password">密码:</label><input type="password" name="password" placeholder="输入密码" id="password"><br>
性别:<input type="radio" name="gender" value="male">男
<input type="radio" name="gender" value="female" checked>女
<br>
爱好:<input type="checkbox" name="hobby" value="sleep" checked>睡觉
<input type="checkbox" name="hobby" value="java">Java
<input type="checkbox" name="hobby" value="game">游戏
<br>
图片:<input type="file" value="file"><br>
隐藏域:<input type="hidden" name="id" value="aaa"><br>
取色器:<input type="color" name="color"><br>
生日:<input type="date" name="birthday"><br>
生日:<input type="datetime-local" name="birthday"><br>
邮箱:<input type="email" name="email"><br>
年龄:<input type="number" name="age"><br>
<br>
<br>
<br>
<br>
省份:
<select name="province">
<option value="" selected>---请选择---</option>
<option value="1">---北京---</option>
<option value="2">---上海---</option>
<option value="3">---湖南---</option>
</select>
<br>
自我描述:
<textarea cols="20" rows="5" name="desc"></textarea><!--cols列 rows行-->
<br>
<input type="submit" value="登陆">
<input type="button" value="按钮"><br>
<input type="image" src="img/regbtn.jpg">
</form>
</body>
</html>
2.HTML表单练习
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="#" method="post">
<table align="center" border="1" width="500">
<tr>
<td><label for="username">用户名</label></td>
<td><input type="text" name="username" id="username"></td>
</tr>
<tr>
<td><label for="password">密码</label></td>
<td><input type="password" name="password" id="password"></td>
</tr>
<tr>
<td><label for="email">邮箱</label></td>
<td><input type="email" name="email" id="email"></td>
</tr>
<tr>
<td><label for="name">姓名</label></td>
<td><input type="text" name="name" id="name"></td>
</tr>
<tr>
<td><label for="phone">手机号</label></td>
<td><input type="number" name="phone" id="phone"></td>
</tr>
<tr>
<td>性别</td>
<td><input type="radio" name="gender" value="male">男
<input type="radio" name="gender" value="female">女
</td>
</tr>
<tr>
<td><label for="birthday">出生日期</label></td>
<td><input type="date" name="birthday" id="birthday"></td>
</tr>
<tr>
<td><label for="yan">验证码</label></td>
<td><input type="text" name="yan" id="yan"><img src="img/verify_code.jpg"></img>></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="注册"></td>
</tr>
</table>
</form>
</body>
</html>
3.HTML和CSS的结合方式–3种
1.内联样式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div style="color: red">hello css</div>
</body>
</html>
2.内部样式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
div{
color: gray;
}
</style>
</head>
<body>
<div>hello css</div>
</body>
</html>
3.外部样式—在另外一个文件定义css语句来装饰html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="css/a.css">
</head>
<body>
<div>hello css</div>
</body>
</html>
/*a.css文件*/
div{
color:green;
}
4.基础选择器
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>基础选择器</title>
<style>
#div1{
color: red;
}
div{
color: yellow;
}
.cls{
color: green;
}
</style>
</head>
<body>
<!--基础选择器
1.id选择器:选择具体的id属性值的元素,建议在一个html文件中id值唯一
2.元素选择器:选择具有相同标签名称的元素
3.类选择器:选择具有相同的class属性值的元素
-->
<div id="div1">奥力给的猛</div>
<div>奥力给的猛啊</div>
<div class="cls">奥力给的猛啊啊啊</div>
</body>
</html>
5.扩展选择器
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>扩展选择器</title>
<!--1.子选择器 2.父选择器 3.并集选择器 4.属性选择器 5.伪类选择器-->
<style>
p,div p{
color: yellow;
}
div > p{
border: 1px solid;
}
input[type="text"]{
border: 5px solid;
}
a:link{
color: pink;
}
a:hover{
color: green;
}
a:active{
color: yellow;
}
a:visited{
color: red;
}
</style>
</head>
<body>
<div>
<p>奥力给的猛</p>
</div>
<p>那就是奥力给的猛</p>
<input type="text">
<br>
<br>
<!--link初始状态 hover悬浮状态 visited访问过的状态 active正在访问状态-->
<a href="#">点点点点</a>
</body>
</html>
6.CSS属性–字体
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>字体属性</title>
<style>
p{
color: #ff0000;
font-size: 30px;
text-align: center;
/*
行高
*/
line-height: 30px;
/*
边框宽度颜色
*/
border: 1px solid red;
}
div{
/*
尺寸
*/
border: 1px solid red;
width: 200px;
height: 200px;
/*
背景
*/
background: url("img/verify_code.jpg") no-repeat center;
}
</style>
</head>
<body>
<p>奥力给的猛</p>
<div>aaaa </div>
</body>
</html>
7.CSS属性–盒子模型
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>字体属性</title>
<style>
div{
border: 1px solid red;
}
.div1{
width: 100px;
height: 100px;
/*
设置 外边距
*/
/*margin: 50px;*/
}
.div2{
width: 200px;
height: 200px;
padding: 50px;
/*设置内边距 需要最终设定盒子的大小 */
box-sizing: border-box;
}
/*
浮动
*/
.div3{
float: left;
}
.div4{
float: left;
}
.div5{
float: right;
}
</style>
</head>
<body>
<div class="div2">
<div class="div1"></div>
</div>
<div class="div3">123</div>
<div class="div4">456</div>
<div class="div5">789</div>
</body>
</html>
8.CSS注册页面 练习
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>注册页面</title>
<style>
*{
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body{
background: url("img/register_bg.png") no-repeat center;
}
.rg_layout{
width: 900px;
height: 500px;
border: 8px solid #EEEEEE;
background-color: white;
/*水平居中*/
margin: auto;
margin-top: 15px;
}
.rg_left{
/*border:1px solid red;*/
float: left;
margin: 15px;
}
.rg_left p[id="p1"]{
color: #ffd026;
font-size: 20px;
}
.rg_left p[id="p2"]{
color: #A6A6A6;
font-size: 20px;
}
.rg_center{
/*border:1px solid red;*/
float: left;
width: 450px;
}
.rg_right{
/*border:1px solid red;*/
float: right;
margin: 15px;
}
.rg_right a{
color: pink;
font-size: 15px;
}
.rg_right{
font-size: 15px;
}
.td_left{
width: 100px;
text-align: right;
height: 45px;
}
.td_right{
padding-left: 50px;
}
#username,#password,#email,#name,#birthday,#phone,#yan{
width: 251px;
height: 32px;
border: 1px solid #A6A6A6;
border-radius: 5px;
padding-left: 10px;
}
#yan{
width: 110px;
}
#imag_yan{
height: 32px;
vertical-align: middle;
}
#btn_sub{
width: 150px;
height: 40px;
background-color: #ffd026;
border: 1px solid #ffd026;
}
</style>
</head>
<body>
<div class="rg_layout">
<div class="rg_left">
<p id="p1">新用户注册</p>
<p id="p2">USER REGISTER</p>
</div>
<div class="rg_center">
<div class="rg_form">
<form action="#" method="post">
<table>
<tr>
<td class="td_left"><label for="username">用户名</label></td>
<td class="td_right"><input type="text" name="username" id="username" placeholder="请输入用户名"></td>
</tr>
<tr>
<td class="td_left"><label for="password">密码</label></td>
<td class="td_right"><input type="password" name="password" id="password" placeholder="请输入密码"></td>
</tr>
<tr>
<td class="td_left"><label for="email">邮箱</label></td>
<td class="td_right"><input type="email" name="email" id="email" placeholder="请输入邮箱"></td>
</tr>
<tr>
<td class="td_left"><label for="name">姓名</label></td>
<td class="td_right"><input type="text" name="name" id="name" placeholder="请输入姓名"></td>
</tr>
<tr>
<td class="td_left"><label for="phone">手机号</label></td>
<td class="td_right"><input type="number" name="phone" id="phone" placeholder="请输入手机号"></td>
</tr>
<tr>
<td class="td_left">性别</td>
<td class="td_right"><input type="radio" name="gender" value="male">男
<input type="radio" name="gender" value="female">女
</td>
</tr>
<tr>
<td class="td_left"><label for="birthday">出生日期</label></td>
<td class="td_right"><input type="date" name="birthday" id="birthday"></td>
</tr>
<tr>
<td class="td_left"><label for="yan">验证码</label></td>
<td class="td_right"><input type="text" name="yan" id="yan" placeholder="请输入验证码"><img src="img/verify_code.jpg" id="imag_yan"></img></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="注册" id="btn_sub"></td>
</tr>
</table>
</form>
</div>
</div>
<div class="rg_right">
<p>已有账号<a href="#">立即登录</a></p>
</div>
</div>
</body>
</html>
界面展示: