html界面介绍
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>我的网页</title>
</head>
<body>
欢迎使用VSCode开发HTML项目
<a href="2.HTML基本标签的使用(一).html">HTML基本标签的使用</a>
</body>
</html>
HTML标签的使用
background:设置背景图片
h:标题标签,HTML中包含6级标题,h1-h6
align:设置对齐方式(left<默认>,center,right)
font:字体标签,用于对字体文本进行设置
size="100":设置字体大小
color="red":设置字体颜色
face="宋体":设置字体类型
p:段落标签
br:换行标签
hr:水平线标签
color="red":设置颜色
width="500":设置水平线宽度
align="left":设置对齐方式
size="10":设置水平线粗细
img:图片标签
src:指定图片的位置
width:设置图片的宽度
height:设置图片的高度
title:设置图片的提示文本
audio:设置背景音乐标签
src:指定音乐的位置(mp3)
autoplay:设置背景音乐是否自动播放
loop:背景音乐的循环播放的方式
video:视频标签
src:指定视频的位置
a:超链接标签(用于与其他页面关联的标签)
href:指定要关联的页面的位置
href属性中的"#"表示当前页,"1"是锚记名**
target="_black":指定连接的目标页面的显示方式为在新 页面中显示(默认替换当前页面)
name:设置超链接的名字(锚记名)
marquee:滚动标签(跑马灯效果)
behavior="alternate":设置滚动方式,默认为scroll
scrolldelay="1":设置滚动延迟时间
scrollamount="50":设置滚动速度
direction="right":设置滚动方向
οnmοuseοver="stop()":当鼠标悬浮时停止
οnmοuseοut="start()":当鼠标离开时让滚动继续
ul:无序列表
type:用于指定项目符号
ol:有序列表
type:用于指定项目符号
li:该标签需要与ul或ol一起使用,表示一个列表项
dl:自定义列表的外围标签
dt:自定义列表的列表标题
dd:自定义列表的列表项
b:加粗标签
i:设置斜体标签
u:加下划线标签
表格标签
表格标签的基本使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>表格标签</title>
</head>
<body>
<table border="1" width="500" background="../images/u=4069854689,43753836&fm=193&f=GIF.jpg" bgColor="yellow" borderColor="red" height="200" align="center" cellspacing="0" cellpadding="0">
<tr align="center" bgColor="cornflowerblue">
<td>序号</td>
<td>姓名</td>
<td>性别</td>
<td>年龄</td>
<td bgcolor="GREEN">地址</td>
</tr>
<tr align="center">
<td>1</td>
<td>小强</td>
<td>男</td>
<td>20</td>
<td>西安市</td>
</tr>
<tr align="center">
<td>2</td>
<td>小花</td>
<td>女</td>
<td>20</td>
<td>商洛市</td>
</tr>
<tr align="center">
<td>3</td>
<td>小胖</td>
<td>男</td>
<td>21</td>
<td>西安市</td>
</tr>
<tr align="center">
<td>4</td>
<td>小瘦</td>
<td>男</td>
<td>22</td>
<td>西安市</td>
</tr>
</table>
</body>
</html>
跨行跨列的表格
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<table border="1" borderColor="red" cellspacing="0" cellpadding="0" align="center" width="600" height="200">
<tr>
<td></td>
<td colspan="3"></td>
</tr>
<tr>
<td rowspan="3"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>
带有列标题的表格
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
tbody tr{
color: red;
}
</style>
</head>
<body>
<table border="1" width="500" background="../images/u=4069854689,43753836&fm=193&f=GIF.jpg" bgColor="yellow" borderColor="red" height="200" align="center" cellspacing="0" cellpadding="0">
<thead>
<tr bgColor="cornflowerblue" height="50">
<th>序号</th>
<th>姓名</th>
<th>性别</th>
<th>年龄</th>
<th bgcolor="GREEN">地址</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>小强</td>
<td>男</td>
<td>20</td>
<td>西安市</td>
</tr>
<tr>
<td>2</td>
<td>小花</td>
<td>女</td>
<td>20</td>
<td>商洛市</td>
</tr>
<tr>
<td>3</td>
<td>小胖</td>
<td>男</td>
<td>21</td>
<td>西安市</td>
</tr>
<tr>
<td>4</td>
<td>小瘦</td>
<td>男</td>
<td>22</td>
<td>西安市</td>
</tr>
</tbody>
</table>
</body>
</html>
table:表格的外框
border="1":表格的边框为1个像素
width="500":设置表格的宽度
height="200":设置表格的高度
align="center":表格在HTML文档中对齐方式
cellspacing:设置单元格与单元格之间的间距
cellpadding:设置填充距离(单元格的边框与内容之间的距离)
borderColor="red":设置表格边框颜色
bgColor:设置整个表格的背景色
background:设置表格的背景图片
tr:行标签
bgColor:行背景色
td:单元格标签(列标签)
bgColor:单元格背景色
colspan:跨列属性(横向跨列)
rowspan:跨行属性(纵向跨行)
th:列标题标签,该标签自带样式(内容居中并加粗显示)
表单标签
两种提交方式:get和post
(1) get:默认的提交方式 (2) post
get与post的区别:
(1) - get提交方式提交的参数在浏览器地址栏中显示(不安全)
- post提交方式提交的参数在浏览器地址栏中不显示(安全)
(2) - get提交方式提交的数量有限,大小不能超过255个字节
- post提交方式提交的数据量无限制(可以提交大数据量表单)
超链接的提交方式为get方式
总结:表单提交都设置为post方式
用户注册
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>用户注册</title>
</head>
<body>
<h2>用户注册</h2>
<form name="registerForm" action="3.2注册成功.html" method="post">
<input type="hidden" value="10" name="userId"/>
<label for="username">用户名:</label><input type="text" id="username" name="username" placeholder="请输入用户名"/>
<br/>
<label>照片:</label><input type="file" name="photo"/>
<br/>
<label for="password">密码:</label><input type="password" name="password" id="password" placeholder="请输入密码"/>
<br/>
<label>性别:</label><input type="radio" name="sex" id="boy" value="男" checked/><label for="boy">男</label>
<input type="radio" name="sex" id="girl" value="女"/><label for="girl">女</label>
<br/>
<label>出生日期:</label><input type="date" name="birthday"/>
<br/>
<label for="age">年龄:</label><input type="number" name="age" />
<br/>
<label>爱好:</label>
<input type="checkbox" name="hobbys" id="hobbys1" value="篮球"/><label for="hobbys1">篮球</label>
<input type="checkbox" name="hobbys" value="逛街"/>逛街
<input type="checkbox" name="hobbys" value="网游"/>网游
<input type="checkbox" name="hobbys" vlaue="睡觉" checked/>睡觉
<br/>
<label>请选择省份:</label>
<select name="province">
<option>---请选择省份---</option>
<option value="sxs">陕西省</option>
<option value="scs">四川省</option>
<option value="hns">河南省</option>
<option value="gss">甘肃省</option>
<option value="sds">山东省</option>
<option value="hbs">河北省</option>
</select>
<br/>
<label for="">自我介绍</label>
<textarea name="jieshao" rows="10" cols="50"></textarea>
<br/>
<input type="submit" value="提交按钮"/>
<input type="reset" value="重置按钮"/>
<input type="button" value="普通按钮"/>
<input type="image" src="../images/u=2141219545,3103086273&fm=193&f=GIF.jpg" width="150" height="50">
<button>提交按钮</button>
<button type="reset">重置按钮</button>
<button type="button">普通按钮</button>
</form>
<button>提交按钮</button>
</body>
</html>
注册成功
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h2 align="center">注册成功</h2>
</body>
</html>
登录
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="3.4登录成功.html" method="post">
<table align="center" border="0" cellspacing="5" width="300" height="80">
<tr>
<td align="right">
<label for="username">用户名:</label>
</td>
<td>
<input type="text" name="username" id="username"/>
</td>
</tr>
<tr>
<td align="right">
<label for="password">密码:</label>
</td>
<td>
<input type="password" name="password" id="password"/>
</td>
</tr>
<tr>
<td colspan="2">
<button>登录</button>
<button type="reset">重置</button>
</td>
</tr>
</table>
</form>
</body>
</html>
CSS的基本使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
p{
color:red;
font-size: 38px;
font-weight: bold;
font-family: "宋体";
}
</style>
</head>
<body>
<p>CSS样式表修饰P标签</p>
<h1>标题标签</h1>
<p>另一个P</p>
</body>
</html>
2、选择器的使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.myClass{
color: red;
font-size: 38px;
font-weight: bold;
}
</style>
</head>
<body>
<p>这是一个段落标签</p>
<h2 class="myClass">这是一个二级标题标签</h2>
<p class="myClass">bold是设置字体粗细的一个加粗值,该值为7(可以简单理解为加粗)</p>
</body>
</html>
3、CSS常用样式表-文本样式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
p{
text-indent: 30px;
text-align: left;
letter-spacing: 2px;
line-height: 30px;
font-size: 26px;
font-family:"宋体";
color: seagreen;
font-weight:bold;
font-style:italic;
text-decoration:underline;
}
</style>
</head>
<body>
<p>
标签选择器:HTML中存在的标签名做为选择器的名字,<br/>则当前页面中同标签的所有元素遵循该样式规则显示
<br/>
类选择器:定义一个类选择器,并在其中定义样式规则,<br/>在需要时使用标签中的class属性调用类选择器;(类选择器的定义:.类名)
</p>
<p>
3.ID选择器:将一个HTML标签中的ID属性做为选择器使用,<br/>ID选择器只能针对同id的标签起作用,不需要调用(ID选择器的定义:#id{})
</p>
<p>
welcome to jiazhong
</p>
</body>
</html>
4、CSS常用样式表-边框样式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
p{
font-size: 26px;
font-family:"宋体";
border-bottom:1px dashed red;
border-left: 1px solid blue;
border-right: 1px double green;
border-top:1px dotted orange;
}
h2{
border: 1px solid red;
}
label{
border: 1px solid red;
}
a{
border: 1px solid red;
}
</style>
</head>
<body>
<p>
标签选择器:HTML中存在的标签名做为选择器的名字,<br/>则当前页面中同标签的所有元素遵循该样式规则显示
<br/>
类选择器:定义一个类选择器,并在其中定义样式规则,<br/>在需要时使用标签中的class属性调用类选择器;(类选择器的定义:.类名)
</p>
<p>
3.ID选择器:将一个HTML标签中的ID属性做为选择器使用,<br/>ID选择器只能针对同id的标签起作用,不需要调用(ID选择器的定义:#id{})
</p>
<p>
welcome to jiazhong
</p>
<h2>二级标题标签</h2>
<label>文本标签</label>
<a href="">超链接</a>
</body>
</html>
5、CSS常用样式表-背景样式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
background-image: url(../images/u=2141219545\,3103086273&fm=193&f=GIF.jpg);
background-repeat: no-repeat;
background-size: 100%;
}
</style>
</head>
<body>
</body>
</html>
6、使用样式表修饰表格
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>表格标签</title>
<style>
table{
width: 800px;
border: 1px solid red;
border-spacing: 0px;
border-collapse: collapse;
text-align: center;
background-image: url(../images/u=3601447414\,1764260638&fm=193&f=GIF.jpg);
background-size:100%;
}
td,th{
border: 1px solid red;
height: 50px;
font-size: 18px;
color:tomato;
}
th{
background-color: silver;
color: snow;
}
</style>
</head>
<body>
<table align="center">
<tr>
<th>序号</th>
<th>姓名</th>
<th>性别</th>
<th>年龄</th>
<th>地址</th>
</tr>
<tr>
<td>1</td>
<td>小强</td>
<td>男</td>
<td>20</td>
<td>西安市</td>
</tr>
<tr>
<td>2</td>
<td>小花</td>
<td>女</td>
<td>20</td>
<td>商洛市</td>
</tr>
<tr>
<td>3</td>
<td>小胖</td>
<td>男</td>
<td>21</td>
<td>西安市</td>
</tr>
<tr>
<td>4</td>
<td>小瘦</td>
<td>男</td>
<td>22</td>
<td>西安市</td>
</tr>
</table>
</body>
</html>
7、使用样式表修改表单
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>用户注册</title>
<style>
table{
width: 600px;
border: 0px solid red;
border-spacing: 0px;
border-collapse: collapse;
font-size: 22px;
}
td{
border: 0px solid red;
height: 50px;
}
td:nth-child(odd){
text-align: right;
padding-right: 10px;
}
.txt{
width: 300px;
height: 40px;
font-size: 20px;
padding-left: 10px;
border: 1px solid tomato;
border-radius: 3px;
outline: none;
background-color:sandybrown;
color: #fff;
margin-bottom: 10px;
}
textarea{
width: 300px;
height: 100px;
outline: none;
background-color:sandybrown;
color: #fff;
font-size: 20px;
border-radius: 3px;
border: 1px solid tomato;
padding-left: 10px;
}
button{
width: 180px;
height: 50px;
border: 0px;
background-color:darkorange;
color: #fff;
border-radius: 5px;
font-size: 20px;
letter-spacing: 3px;
cursor: pointer;
}
button:hover{
background-color:red;
}
button:active{
box-shadow: 0px 0px 10px rgb(76, 104, 231);
}
</style>
</head>
<body>
<h2 align="center">用户注册</h2>
<form name="registerForm" action="3.2注册成功.html" method="post">
<table align="center">
<tr>
<td><label for="username">用户名:</label></td>
<td>
<input class="txt" type="text" id="username" name="username" placeholder="请输入用户名" />
</td>
</tr>
<tr>
<td><label for="password">密码:</label></td>
<td>
<input class="txt" type="password" name="password" id="password" placeholder="请输入密码" />
</td>
</tr>
<tr>
<td>
<label>性别:</label>
</td>
<td>
<input type="radio" name="sex" id="boy" value="男" checked /><label for="boy">男</label>
<input type="radio" name="sex" id="girl" value="女" /><label for="girl">女</label>
</td>
</tr>
<tr>
<td>
<label>出生日期:</label>
</td>
<td>
<input class="txt" type="date" name="birthday" value="2020-10-10" />
</td>
</tr>
<tr>
<td>
<label>爱好:</label>
</td>
<td>
<input type="checkbox" name="hobbys" id="hobbys1" value="篮球" /><label for="hobbys1">篮球</label>
<input type="checkbox" name="hobbys" value="逛街" />逛街
<input type="checkbox" name="hobbys" value="网游" />网游
<input type="checkbox" name="hobbys" vlaue="睡觉" checked />睡觉
</td>
</tr>
<tr>
<td>
<label>请选择省份:</label>
</td>
<td>
<select class="txt" name="province">
<option>---请选择省份---</option>
<option value="sxs">陕西省</option>
<option value="scs">四川省</option>
<option value="hns">河南省</option>
<option value="gss">甘肃省</option>
<option value="sds">山东省</option>
<option value="hbs">河北省</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="">自我介绍:</label>
</td>
<td>
<textarea name="jieshao"></textarea>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center;">
<button>提交按钮</button>
<button type="reset">重置按钮</button>
</td>
</tr>
</table>
</form>
</body>
</html>
8、其他样式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" contfloat:left;nt="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
li{
list-style: none;
float:left;
}
p{
border: 1px solid red;
width: 500px;
height: 100px;
}
span{
border:1px solid red;
width: 500px;
height: 100px;
display: inline-block;
margin-top:50px;
padding-left: 50px;
padding-top:30px;
}
</style>
</head>
<body>
<ul>
<li>注册</li>
<li>登录</li>
<li>查看商品</li>
<li>购买</li>
</ul>
<p>
</p>
<span>
span
</span>
</body>
</html>
9、超链接样式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
a:link{
text-decoration: none;
letter-spacing: 2px;
margin:10px;
font-weight: bold;
}
a:visited{
color: yellowgreen;
}
a:hover{
color: red;
}
a:active{
font-size: 20px;
}
</style>
</head>
<body>
<a href="8.其他样式.html">其他样式</a>
<a href="7.使用样式表修饰表单.html">表单修饰</a>
</body>
</html>
10、使用超链接实现页面导航效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
ul{
border: 0px solid red;
padding-left: 0px;
display: flex;
flex-direction: row;
justify-content: center;
}
li{
list-style: none;
}
a:link{
text-decoration: none;
color: blue;
}
a:visited{
color: blue;
}
a:hover{
color: red;
}
a:active{
color: yellowgreen;
}
a.nav:link{
border: 1px solid #fff;
border-radius: 5px;
width: 150px;
height: 60px;
display: inline-block;
text-decoration: none;
text-align: center;
line-height: 60px;
background-color: darkorange;
color: #fff;
font-size: 20px;
letter-spacing: 5px;
font-weight: bold;
}
a.nav:visited{
border: 1px solid #fff;
width: 150px;
height: 60px;
display: inline-block;
text-decoration: none;
text-align: center;
line-height: 60px;
background-color: darkorange;
color: #fff;
font-size: 20px;
letter-spacing: 5px;
font-weight: bold;
}
a.nav:hover{
background-color:greenyellow;
}
</style>
</head>
<body>
<ul>
<li>
<a href="#" class="nav">首页</a>
</li>
<li>
<a href="#" class="nav">教育</a>
</li>
<li>
<a href="#" class="nav">财经</a>
</li>
<li>
<a href="#" class="nav">军事</a>
</li>
<li>
<a href="#" class="nav">抗疫</a>
</li>
<li>
<a href="#" class="nav">台湾</a>
</li>
<li>
<a href="#" class="nav">影视</a>
</li>
<li>
<a href="#" class="nav">音乐</a>
</li>
<li>
<a href="#" class="nav">综艺</a>
</li>
<li>
<a href="#" class="nav">关于我们</a>
</li>
</ul>
<p>
<a href="">进入查看</a>
</p>
</body>
</html>
11、透明样式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
background-image: url(../images/u=350949237\,2668017024&fm=193&f=GIF.jpg);
background-repeat: no-repeat;
background-size: 100%;
background-attachment:fixed;
overflow: hidden;
}
p{
width: 100%;
height: 300px;
text-align: center;
line-height: 300px;
font-size: 100px;
font-weight: bold;
color: rgba(0, 0, 255,.5);
}
div{
width: 90%;
height: 100px;
border-radius: 10px;
background-color:rgba(255, 255, 255, .7);
padding-left: 10px;
padding-top: 5px;
}
</style>
</head>
<body>
<div>
快过年了,要放假了!
</div>
<p>
CSS半透明字体
</p>
<p>
CSS半透明字体
</p>
<p>
CSS半透明字体
</p>
<p>
CSS半透明字体
</p>
<p>
CSS半透明字体
</p>
<p>
CSS半透明字体
</p>
<p>
CSS半透明字体
</p>
<p>
CSS半透明字体
</p>
<p>
CSS半透明字体
</p>
<p>
CSS半透明字体
</p>
<p>
CSS半透明字体
</p>
<p>
CSS半透明字体
</p>
</body>
</html>
12、阴影样式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
p{
height: 100px;
text-align: center;
font-size: 100px;
font-weight: bold;
color: red;
letter-spacing: 30px;
text-shadow: 0px 0px 20px rgb(247, 247, 2);
}
div{
margin:0 auto;
width: 600px;
height: 200px;
background-color: rgb(159, 243, 4);
border: 0px solid red;
border-radius: 10px;
box-shadow: 0px 0px 20px red;
}
</style>
</head>
<body>
<p>
阴影字体
</p>
<div>
</div>
</body>
</html>
13、过度效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{
margin:0 auto;
width: 500px;
height: 500px;
background-color: red;
}
div:hover{
cursor: pointer;
background-color:yellowgreen;
transition: background-color 2s linear 500ms;
}
p{
width: 10px;
height: 100px;
background-color: red;
transition: width 5s linear 500ms,height 5s linear 500ms;
}
p:hover{
cursor: pointer;
width: 100%;
height: 800px;
transition: width 5s linear 500ms,height 5s linear 500ms;
}
</style>
</head>
<body>
<div></div>
<p></p>
</body>
</html>
14、动画效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{
position: absolute;
top:10px;
left:10px;
width: 100px;
height: 100px;
background-color: red;
}
@keyframes move {
from{
left:10px;
}
to{
left:1300px;
}
}
</style>
</head>
<body>
<div></div>
<br/><br/><br/><br/><br/><br/>
<button onclick="moveTest()">动起来</button>
<script>
function moveTest(){
let divObj = document.querySelector("div");
divObj.style.animation="move 2s 0s";
divObj.style.animationFillMode="forwards";
}
</script>
</body>
</html>