H5

前端大纲

前端

 

1 什么是前端

前端即网站前台部分,运行在PC端,移动端等浏览器上展现给用户浏览的网页。随着互联网技术的发展,HTML5,CSS3,前端框架的应用,跨平台响应式网页设计能够适应各种屏幕分辨率,完美的动效设计,给用户带来极高的用户体验。

前端技术一般分为前端设计和前端开发,前端设计一般可以理解为网站的视觉设计,前端开发则是网站的前台代码实现,包括基本的HTML和CSS以及JavaScript

2 前端开发的技术栈

HTML

  • 超文本标记语言 Hyper Text Markup Language

  • “超文本”就是指页面内可以包含图片、链接,甚至音乐、程序等非文字元素

  • 负责完成页面的结构

CSS

  • 级联样式表 Cascading Style Sheet

  • 负责页面的风格设计,样式、美观

JavaScript

  • 浏览器脚本语言,可以编写运行在浏览器上的程序

  • 妥妥的编程语言

  • 负责编写页面特效、调用浏览器的API(BOM)、操作改变页面内容(DOM),从后端获取数据(Ajax),渲染页面等

  • jQuery是JavaScript的一个库

  • Vue、Angular、React 等是JavaScript 框架

第一节---HTML

1 HTML 基本语法

html标签

  • 单标签 <img /><img>

  • 双标签 <html> </html>

属性 属于标签

<img src="图片的地址">
<table width="100" height="200"></table>

语法规范

  • 标签嵌套 用缩进

  • 标签名 不区分大小写 建议小写

  • 属性名 不区分大小写 建议小写

注释

<!-- 多行 -->
<!--
多行
-->

网站的搜索引擎优化(指定网站的源信息)

<meta charset="utf-8">
<meta name="keywords" content="默默交友,交友平台,90相亲">  
<meta name="description" content="内容简介">

网站的图标

<link rel="shortcut icon" type="image/x-icon" href="kuaibo.jpg">

 

常用HTML实体

  • &nbsp; 空格

  • &lt; <

  • &gt; >

  • &amp; &

  • &copy; 版权

  • &yen; 人民币

 

2 HTML常用标签

主体结构

  • <html></html>

  • <head></head>

  • <body></body>

HEAD标签

  • <title></title> 网站标题

  • <meta> 指定网页的元信息 指定关键字 指定描述 指定字符集 属性: charset、name、content

  • <style></style>

  • <link> 导入css或者指定网页图标 属性 src、 type 、 rel

  • <script></script> 导入javascript

格式排版标签

  • <hn></hn> 1~6 标题

  • <p></p> 段落

  • <pre></pre> 原样输出

  • <br> 换行

  • <hr> 分隔

  • <div></div>

文本标签

  • <em></em> 强调 表现为斜体

  • <strong></strong> 强调 表现为粗体

  • <mark></mark> H5新增 表示被选择

  • <sup></sup> 上标

  • <sub></sub> 下标

  • <ins></ins> 添加的内容

  • <del></del> 删除的内容

  • <ruby></ruby> / <rt></rt> 加拼音 H5新增

    <ruby>
    默默 <rt>momo</rt>
    </ruby>

     

 

4 CSS基本语法

使用CSS

  • link 引入外部的CSS文件

  • <style></style> 在html中写

  • 使用html元素的style属性

格式

选择器 {
   CSS属性: 值;
   CSS属性: 值;
}

选择器 {属性:值;属性:值}

注释

/*  */

 

CSS长度单位

px  像素
em 默认大小的倍数
百分比   默认大小参照
cm 非常不推荐使用
mm 非常不推荐使用

CSS 颜色单位

colorName:  red/green/bue/purple/orange/yellow/pink/skyblue

rgb数字 rgb(34,45,23) rgb(20%, 57%, 100%)
r占一个字节 8个bit位  

16进制   #abcdef   #f90   #ccc

# 8位二进制对应2位十六进制

# 000 是最黑 fff是白

小案例:

div {
width: 400px;
height: 400px;
border: 2px dotted red;

background-color: purple;

/*
R 红
G 绿
B 蓝
*/
background-color: rgb(100, 200, 50);
background-color: rgb(100%, 50%, 10%);

/*
            十六进制
*/
background-color: #ab1234;
background-color: #abcdef;
background-color: #336699;
background-color: #369;
background-color: #f90;

background-color: #fff;
background-color: #000;

background-color:#c1c1c1;
}

 

5 CSS选择器

#标签名选择器
tagName {
   
}

# 类名
.className {
   
}

#ID选择器
#idName {
   
}


# 全局选择器
* {
   
   
}


# 组合 后代元素
选择器 选择器

# 组合 子元素
选择器>选择器

# 群组
选择器,选择器,选择器

# 多条件
p.item

选择器小案例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
/*ID选择器*/
#myFriend {
color: #f90;
}


/*CLASS选择器*/
.first-item {
width: 900px;
}

.item {
width: 700px;
padding: 20px;
border: 1px solid #369;
}

* {
/*border:2px solid red;*/
}


.list li {
/*border: 1px solid orange;*/
}

.list>li ol {
color:red;
border: 1px solid blue;
}

/*群组选择器 或者 or*/
h1,hr,p,.item {

}

/* and */
p.item {

}

.item.first-item{
color: orange;
}


</style>
</head>
<body>
<h1 id="yourFrind">CSS选择器</h1>
<hr>

<ul>
<li>啊手动阀</li>
<li>啊手动阀</li>
<li>啊手动阀</li>
</ul>

<hr>

<ul class="list">
<li>发射</li>
<li>发射</li>
<li>发射
<ol>
<li>子</li>
<li>子</li>
<li>子</li>
<li>子</li>
</ol>
</li>
<li>加特林</li>
<li>加特林</li>
<li>加特林</li>
<li>加特林</li>
</ul>

<p class="item">撒旦萨芬记录卡是否健康拉法基</p>
<p class="first-item item">杀杀杀一号</p>
<p>撒旦萨芬记录卡是否健康拉法基</p>
<p id="myFriend">撒旦萨芬记录卡是否健康拉法基</p>
<p>撒旦萨芬记录卡是否健康拉法基</p>
<p class="item">撒旦萨芬记录卡是否健康拉法基</p>
<p>撒旦萨芬记录卡是否健康拉法基</p>
<hr>
<div class="item">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</body>
</html>

 

6 选择器优先级

ID > CLASS > tagName > *

组合选择器 数数

 

 

7 CSS属性 常用

字体

  • font-family #指定字体家族 分为衬线字体 和非衬线字体 如 font-familly:‘宋体’;

  • font-size # 指定字体大小

  • font-weight normal/bold #指定是否加粗

  • font-style normal/ italic /oblique # 指定是否倾斜 注意italic调用的是字体自带的斜体设计(推荐使用)

  • font-variant normal/small-caps # 指定小型大写英文字母 对于中文没有什么意义

  • font 复合属性(推荐使用)

    font:[weith | style | variant] size family

字体家族小案例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>默默交友</title>
<style type="text/css">

p {
font-family: 'Microsoft YaHei','宋体','楷体',sans-serif;
/*
            字体家族
            非衬线字体: 微软雅黑 黑体 思源黑体   sans-serify
            衬线字体: 宋体 楷体 仿宋 serify
*/

font-size:30px;
font-weight: bold;
font-variant: small-caps;
font-style: italic;

font: 12px '微软雅黑',sans-serify;
font: bold 12px '微软雅黑',sans-serify;
font: bold italic 12px '微软雅黑',sans-serify;
}
</style>
</head>
<body>
<h1>常用属性-字体属性</h1>
<hr>

<p>
天龙盖地虎 小鸡炖蘑菇
</p>
</body>
</html>

 

颜色

  • color 文字颜色

 

文本

  • word-spacing # 词的间距 (依据空格来判定)

  • letter-spacing # 字母间隔(也可以理解为字符间隔)

  • text-align: left / center /right # 文字的横向排列 文字左对齐 居中对齐 右对齐

  • vertical-align: baseline / middle .... # 垂直对齐方式 (注意可以使得图片和文字在一行的小作用)

  • line-height 行高 如果设置的和外面的元素的高度一致可以实现垂直居中

    • 行高可以理解为两个元素基线之间的距离

  • text-decoration : none/overline/underline/line-through #文字修饰 上划线 下划线 删除线

    • 注意这个none可以专门针对a元素去掉a元素的下划线

  • text-indent: 2em # 首行缩进

  • word-wrap: break-word # 允许长单词或者url可以在超出界限的时候自动换行(默认是不会自动换行)

  • overflow-wrap word-wrap的别名 CSS3

  • white-space

    • pre 格式话输出 长单词或url不会自动换行

    • pre-wrap 格式话输出 长单词或url会自动换行

文本小案例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>同志交友</title>
<link rel="stylesheet" type="text/css" href="">
<style type="text/css">
.text {
width: 600px;
height: 200px;
border: 1px solid #ccc;

color: #369;

/*letter-spacing: 10px;*/
/*word-spacing: 30px;*/

text-decoration: underline;
text-decoration: overline;
text-decoration: line-through;

/*text-align: left;*/
text-align: right;
text-align: center;

/*vertical-align: middle;*/


/*text-indent: 30px;*/

line-height: 200px;
}

a {
text-decoration: none;
}

img {
width:100px;
/*vertical-align: middle; */
/*这个可以对准旁边的基线 也就实现了图片和文字的居中对齐 没啥卵用 */
}

.content {
width: 400px;
padding: 20px;
border: 1px solid #ccc;

word-wrap: break-word;
}

.box {
width: 600px;
padding: 20px;
border: 1px solid #ccc;

white-space: pre;
/*white-space: nowrap;*/
/*white-space: nowrap;*/
white-space: pre-wrap;
white-space: pre-line;
}
</style>
</head>
<body>
<h1>CSS文本属性</h1>
<hr>

<p class="text">
我很帅 i am very shuai
</p>
<hr>

<a href="http://www.baidu.com">百度</a>

<div >
<img src="./juhua.jpg" style="width:100">
让我掉下眼泪的不止昨夜的酒
</div>

<hr>

<p class="content">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod   sdfasdfajsdkfjaskdfjaksldfjaklsfjaskldfjskladfjsklafjdklasfjklasjdfkalsjdfklasjdfklasdfjklasdfjklasdfjklasdfjklasfjdklasfjsklafdj

http://unclealan.cn/docs/python/frontend/chapter1/html3css3ji-chu.html
</p>

<hr>

<div class="box">
if a > 100:
print('NB')
msg = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod "
</div>
</body>
</html>

 

第二节---CSS 属性/尺寸/边框/背景

1 CSS 属性/尺寸/边框/背景

尺寸

  • width max-width min-width

  • height max-height min-height

边框

  • border-style 边框风格 solid / dotted / dashed / double / none

  • border-width 边框宽度

  • border-color 边框颜色

  • border 复合属性 border: 1px solid #ccc

 

内边距

  • padding-left

  • padding-top

  • padding-right

  • padding-bottom

  • padding

    padding: 值;  上下左右
    padding: 值1 值2;   上下 左右
    padding: 值1 值2 值3; 上 左右 下
    padding: 值2 值2 值3 值4; 上 右 下 左

 

背景属性

  • background-color 背景颜色

  • background-image 背景图片 url()

  • background-repeat 背景图片平铺 repeat no-repeat repeat-x repeat-y

  • background-position 背景图片位置

    • /*背景图片 的位置*/
      background-position: left top;
      background-position: left center;
      background-position: center center;
      background-position: 10px 10px;

       

  • background-attachment 背景图片固定 scroll / fixed

  • background 复合属性

    background: color image repeat postion attachment
背景图片小案例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>同志约会</title>
<style type="text/css">
.item {
width: 600px;
height: 300px;
border: 2px solid #f90;

/*背景*/
/*背景颜色*/

/*背景图片*/
background-image: url("../../dist/images_two/fenju.jpg");
/*背景图片平铺设置*/
/*background-repeat: repeat;
background-repeat: no-repeat;
background-repeat: repeat-x;
background-repeat: repeat-y;*/
/*背景图片 的位置*/
background-position: left top;
background-position: left center;
background-position: center center;
background-position: 10px 10px;

/*背景图片固定*/
background-attachment: fixed;


background: #aaa url('../../dist/images_two/bg02.jpg') no-repeat 20px 10px;

}


#nav {
height: 300px;
background-image: url('../../dist/images_two/bg02.jpg');
background-attachment: fixed;
}
</style>
</head>
<body>
<h1>背景属性</h1>
<hr>
<div id="nav"></div>

<div class="item"></div>

<div style="height:2000px"></div>
</body>
</html>

 

第三节----表单,表格

表格

2 表格

2.1 HTML标签

<table></table>
<thead></thead>
<tbody></tbody>
<tfoot></tfoot>  
<caption></caption> 标题
<tr></tr> 行
<td></td> 单元格
<th></th> 表头单元格

 

2.2 CSS属性

table-layout: auto / fixed   列宽固定(相等)
border-collapse: separate/ collapse 合并单元格边框
border-spacing: 长度; 单元格和单元格之间的间隙 单元格不能合并
caption-side: top/bottom 标题的位置
empty-cells:hide/show   空的单元格显示/隐藏 单元格不能合并

 

2.3 合并单元格

td或者th的属性:
colspan 跨列
rowspan 跨行

 

表格小案例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>表格</title>
<style type="text/css">
table {
width: 600px;
/*只要是有内容会给出默认的宽度*/

/*设置表格外面的大框架*/
border: 1px solid #999;

/*固定每一列的宽度 等宽*/
table-layout: fixed;


/*设置单元格与单元格的空隙大小
前提但是单元格边框不能合并*/
border-spacing: 10px;


/*合并单元格边框*/
border-collapse: collapse;

/*设置标题的位置   */
{#caption-side: top;#}
caption-side: bottom;

empty-cells: show;  /*显示空单元格*/
empty-cells: hide;
           /*隐藏空单元格
生效的前提是,不能合并单元格边框*/

}

td,th{
/*只有 给这里面的每个单元格都
做出来边框的效果 才有了上面的
关于 合并边框的操作 设置边框的宽度 */
padding: 5px;
border: 1px solid #999;

/*文本居中对齐*/
text-align: center;
}







</style>
</head>
<body>
<h1>同志交友</h1>
<hr>
<table class="first-table">
<!-- 这个是外面的 内容 -->
<caption>同志信息统计</caption>
<!-- 表头头部 -->
<thead>
<!-- 行 tablerow 包含表头单元格th -->
<tr>
<th>序号</th>
<th>姓名</th>
<th>年龄</th>
<th>身高</th>
<th>体重</th>
<!-- style="width: 200px" -->
<th>饭量</th>
</tr>
</thead>

<tbody>
<!-- 行 tablerow 包含普通单元格td -->
<tr>
<td>1</td>
<td>刘表</td>
<td></td>
<td>154</td>
<td></td>
<td>一头牛</td>


</tr>

<tr>
<td>1</td>
<td>张飞</td>
<td>22</td>
<td>155</td>
<td>90</td>
<td>两只鸡</td>


</tr>
<tr>
<td>3</td>
<td>曹汝霖</td>
<td>16</td>
<td>165</td>
<td>80</td>
<td>一头猪</td>
</tr>

<tr>
<td>4</td>
<td>曹冲</td>
<td>12</td>
<td>165</td>
<td>80</td>
<td>一头大象和一头犀牛以及一头河马</td>
</tr>


</tbody>

<tfoot>
<tr>
              <!-- 表示这个单元格占6个长度 -->
<td colspan="6">统计 :共计4人</td>
</tr>
</tfoot>

</table>

</body>
</html>

如果想跨行,下一行或下几行的该列留出来空位

        <tr>
           <td>1</td>
           <td rowspan="2">李白</td>
           <td>19</td>
           <td>一只鸡</td>
       </tr>

       <tr>
           <td>1</td>

           <td>19</td>
           <td>一只鸡</td>

如果想跨列 紧跟着那几个td就不能写了

需求实现下图

答案:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>表格</title>
<style>
table {
width: 600px;
table-layout: fixed;
border-collapse: collapse;
}
td,th {
border: 1px solid #999;
padding: 5px;
text-align: center;
}
table tr {
height: 40px;
}
</style>
</head>
<body>

<table>
<caption><h2>个人信息</h2></caption>
<tr>
<th>姓名</th>
<td></td>
<th>年龄</th>
<td></td>
</tr>

<tr>
<th>性别</th>
<td></td>
<th>饭量</th>
<td></td>
</tr>

<tr>
<th>自我介绍</th>
<td colspan="3"></td>
</tr>

<tr>
<th rowspan="6" colspan="2">工作经历</th>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
</table>
</body>
</html>

 

 

表单

3.1 表单的组成(控件)

文本输入框

<input name="" type="text">
placeholder
maxlength
value



<input type="text"
name="username"
placeholder="请输入用户名"
maxlength="10"
pattern="\w{3,5}"
title="请输入3到5位">

密码框

<input name="" type="password">
placeholder
maxlength
value


<input type="password"
name="pwd"
placeholder="请输入密码">

单选按钮

<input type="radio" name="" value="" checked>



<!--单选按钮-->
<!--这里我们提交的是values-->
<!--这里我们通过一个name值 让他们属于同一个多选一-->
<input type="radio" name="sex" value ='male'> 男
<input type ="radio" name="sex" value="female">女
<!-- 这里的checked是 我们上来的默认选项-->
<input type ="radio" name="sex" value="other" checked>其他

复选框

<input type="checkbox" name="" value="" checked>

<input type="checkbox" name="aihao" value="swim">游泳
<input type="checkbox" name="aihao" value ="drink" checked> 喝
<input type="checkbox" name="aihao" value="sleep" checked> 睡
<input type="checkbox" name="aihao" value="play">玩

文件选择

<input type="file" name="">
multiple 多个

<input type="file" name="avator"  multiple>

规定类型的文本输入框 (H5)

input:email
input:url
input:number   max/min/step

input:tel

<input type="email" name="email" placeholder="请输入邮箱">


<input type="number"
name="score"
max="1000"
min="0"
step="0.1"
placeholder="请输入数字"
>

 

颜色选择(H5)

<input type="color" name="color">

时间日期(H5)

<!--日期-->
<input type="date" name="date">

<!--月份-->
<input type="month" name="month">

<!--星期-->
<input type="week" name="week">

<!--时间-->
<input type="time" name="time">

<!--时间日期-->
<input type="datetime-local" name="dt">

 

 

多行文本

<textarea name="" rows="" cols=""></textarea>
maxlenth

 

按钮

<form action ="1.php" style="width: 400px">
        <!--定义围绕表单中元素的边框-->
        <fieldset>
            <!--定义标签主题-->
            <!--没啥语义-->
            <legend>注册</legend>
            <!--autocomplete 不会自动保存-->
            username: <input type="text" name="username" autocomplete="off"><br>
            password: <input type="password" name="pwd"><br>
            <button>提交</button>
        </fieldset>

</form>

 

 

 

 

###

第四节---盒子模型以及定位

伪类选择器

/*语法*/
selector:伪类 {
 
}

 

:visited  访问过的超链接
:hover    鼠标悬停 任意元素

 

盒子模型

  • 任意一个元素都可以当做盒子模型

  • 盒子的大小 内容宽高(width/height) + 边距(padding)+边框(border)

  • 盒子有外边距,影响盒子的位置

    margin也有上下左右
    margin: 10px 20px 30px 40px;依次是上、右、下、左
    3位是上、左右、下
    两位上下、左右
    一位上下左右都是;
    

边框圆角

border-radius 长度单位
border-top-left-radius
border-top-righ-radius
border-bottom-left-radius
border-bottom-right-radius

边框圆角小案例

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS3边框</title>
<style>
.item {
display: inline-block;
width: 200px;
height: 200px;
border: 1px solid red;
}
.item01 {
border-radius: 100px;
}
.item02 {
/*先写垂直方向再写水平方向的*/
/*左上角*/
border-top-left-radius: 100px;
/*右下角*/
border-bottom-right-radius: 20px;
}
</style>
</head>
<body>
<div class="item item01"></div>
<div class="item item02"></div>
<div class="item item03"></div>
</body>
</html>

 

阴影

box-shadow:水平偏移 垂直偏移;   偏移可以负值
box-shadow:水平偏移 垂直偏移 颜色;
box-shadow:水平偏移 垂直偏移 模糊值 颜色; /*最常见的*/
box-shadow:水平偏移 垂直偏移 模糊值 外延值 颜色;

右正 下正

阴影小案例

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>盒子阴影</title>
<style>
.item {
display: inline-block;
margin:20px;
width: 100px;
height: 100px;
border: 1px solid #999;
}

.item01 {
box-shadow: 3px 3px;
}
.item02 {
box-shadow: 3px 3px #ccc;
}
.item03 {
/*大部分 需要设置这个几个值*/
box-shadow: 3px 3px 5px #ccc;
}
.item04 {
/*外延值*/
box-shadow: 0px 3px 3px 3px #ccc;
}

.item05 {
/*多重阴影*/
box-shadow: 0px 0px 3px 5px red,
0px 0px 3px 10px orange,
0px 0px 3px 15px yellow,
0px 0px 3px 20px green,
0px 0px 3px 25px cyan,
0px 0px 3px 30px blue,
0px 0px 3px 35px purple;
}
</style>
</head>
<body>
<h1>阴影</h1>
<hr>


<div class="item item01">01</div>
<div class="item item02">02</div>
<div class="item item03">03</div>
<div class="item item04">04</div>
<div class="item item05">05</div>
<div class="item item06">06</div>

<hr>


</body>
</html>

 

背景

background-size: cover / contain / 400px 300px / 100% 100%
background: color image postion/size repeat attachment

背景小案例

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>背景</title>
<style>
.item {
width: 200px;
height: 150px;
border: 1px solid #ccc;
background: url('../../dist/images_one/Meinv02.jpg') no-repeat;

/*设置背景图片的尺寸*/
background-size: cover; /*优先 铺满元素。 多余的图片裁掉 保证原图比例*/

/*优先 保证图片显示完整,可能元素不能铺满。 保证原图比例*/
background-size: contain;

/*指定背景图的大小*/
background-size:100px 200px;

background-size:100% 100%;
/*自动适应大小 不能保证原图比例*/


background: url('../../dist/images_one/Meinv02.jpg') 0px 0px/cover no-repeat;
/*0px 0px/cover 保证他俩的顺序不变就可以*/
}
</style>
</head>
<body>
<div class="item">

</div>
</body>
</html>

 

变换

CSS3变换

  • transform

    translatex() 
    translatey()
    translate(x, y) 水平位移
    rotate() 角度 deg
    skewx()  角度deg 了解
    skewy()  扭曲
    skew(x, y)
    
  • transform-origin 变换的原点。 对translate没有意义。 对rotate影响大

 

变换小案例

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>变换</title>
<style>
.box {
display: inline-block;
margin: 30px;
width: 100px;
height: 100px;
border:2px dashed orange;

vertical-align: middle;
}
.item {
border: 1px solid #999;
background: #ccc;
height:99px;
}

.item01 {
/*位移 移动*/
transform: translate(-10px, -10px);
/*x轴y轴*/
transform: translatex(10px) translatey(10px);
/*transform: translatey(10px);*/
}

.item02 {
/*旋转 deg角度 0~360deg*/
transform: rotate(10deg)
}

.item03 {
/*扭曲 x倾斜 y倾斜*/
transform: skewx(10deg) skewy(10deg);
}

.content {
margin: 30px;
width: 100px;
height: 100px;
border: 1px solid #999;
transform: rotate(10deg);
transform-origin: left top;
}
</style>
</head>
<body>

<div class="box">
<div class="item item01"></div>
</div>

<div class="box">
<div class="item item02">HELLO</div>
</div>

<div class="box">
<div class="item item03">HELLO</div>
</div>

<hr>


<div class="content">
HELLO
</div>
</body>
</html>

 

过渡效果

哪些CSS属性可以过渡

长度 (padding margin width height  left/top/right/bottom border-width  background-position ...)
颜色
变换
纯数字 (opacity)

触发过渡

伪类触发  :hover  

相关属性

transition-property  指定要过渡的属性 用,隔开。默认是 all
transition-duration  过渡持续时间
transition-timing-function  过渡线性效果  默认 ease平滑过渡  linear:线性过渡 
transition-delay   过渡延迟
transition:property timing-function duration delay
		    all      ease                 3s   2s

过渡小实例

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>过渡实例</title>
<style>
.item {
/*display: inline-block;*/
width: 100px;
height: 100px;
border: 1px solid #ccc;
text-align: center;
line-height: 100px;
border-radius: 50px;
font-size:30px;
cursor:pointer;

/*过渡*/
transition: transform 1s;
}

.item:hover {
transform: rotate(360deg)
}
</style>
</head>
<body>
<h1>同志</h1>
<hr>

<div class="list">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
</body>
</html>

 

posted @ 2019-05-13 17:46  17111204038  阅读(207)  评论(0)    收藏  举报