01-盒子模型
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div {
width: 300px;
height: 300px;
background-color: pink;
padding-left: 4px;
border: 3px solid red;
margin: 50px;
}
</style>
</head>
<body>
<div>
ffffffffyttttttyyyyyyyybhbhjjjjjj
</div>
</body>
</html>
02-内边距
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div {
width: 600px;
height: 600px;
background-color: aquamarine;
padding-left: 20px;
padding-top: 20px;
padding-right: 20px;
padding-bottom: 20px;
/* padding: 10px 60px 60px 10px;
上 右 下 左 */
}
</style>
</head>
<body>
<div>
idoxenrfskrikcxjnmiokklgtdogmicjtdpxekmzwsfioprelf
ksxcsiojxrocuxrlzifxlizjrsuinaxlirufnrjrknfiuxrzwsdjozswrfxxv
xzejronzuixjknsxfhzaljfuziounujckiunxr;fnxlauirzoicfde
zxerfjibenzxviujkernfslixbfliuzeahinxfpviulceabkjxfrczrxf
zxeiorjzfoesahzxuiozandp;zaowidjxh;ofhco/anxklzjfia;xzejr
zxafjgb.euiaxhbzxvyheul,bxvckzjebcvliuewzdzwjfxluifcxbui,
</div>
</body>
</html>
03-外边距
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
ul li {
list-style: none;
background-color: aqua;
margin-bottom: 30px;
}
span {
display: inline-block;
width: 40px;
background-color: aqua;
padding-left: 4px;
}
div {
width: 300px;
height: 300px;
background-color: bisque;
padding-left: 4px;
border: 3px solid red;
margin: 40px;
}
</style>
</head>
<body>
<ul>
<li>1111</li>
<li>1111</li>
<li>1111</li>
<li>1111</li>
</ul>
<span>1</span><span>2</span><span>3</span><span>4</span>
<div>wioedjmioeafhjdfniohfncurf</div>
</body>
</html>
04-外边距塌陷问题
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.father {
width: 400px;
height: 400px;
background-color: blue;
/*解决方法1: border: 1px solid red; */
/*解决方法2: padding: 1px; */
}
.son {
width: 100px;
height: 100px;
background-color: aqua;
margin-bottom: 20px;
/*解决方法3: overflow: hidden; ------偏方*/
}
.son1 {
margin-top: 300px;
}
/* margin塌陷问题
父元素的第一个元素的margin
解决方法:给父元素添加边框
*/
</style>
</head>
<body>
<div class="father">
<div class="son son1">111</div>
<div class="son son2">222</div>
<div class="son son3">333</div>
</div>
<span>odxxaolxm,dpoeacmpocakpocx</span>
</body>
</html>
05-文本溢出
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div {
width: 100px;
height: 100px;
background-color: aquamarine;
/* overflow:auto; */
/* overflow: hidden; */
/* overflow:visible;s */
/* overflow 尽量远离 */
}
</style>
</head>
<body>
<div>
Lorem, ipsum dolor sit amet consectetur adipisicing elit.
Enim nulla tempore facilis, harum provident porro, delectus tenetur commodi culpa eius veritatis.
Reiciendis ea exercitationem quasi reprehenderit pariatur quos. Repellat, ratione!
Lorem, ipsum dolor sit amet consectetur adipisicing elit.
Enim nulla tempore facilis, harum provident porro, delectus tenetur commodi culpa eius veritatis.
Reiciendis ea exercitationem quasi reprehenderit pariatur quos. Repellat, ratione!
Lorem, ipsum dolor sit amet consectetur adipisicing elit.
Enim nulla tempore facilis, harum provident porro, delectus tenetur commodi culpa eius veritatis.
Reiciendis ea exercitationem quasi reprehenderit pariatur quos. Repellat, ratione!
Lorem, ipsum dolor sit amet consectetur adipisicing elit.
Enim nulla tempore facilis, harum provident porro, delectus tenetur commodi culpa eius veritatis.
Reiciendis ea exercitationem quasi reprehenderit pariatur quos. Repellat, ratione!
Lorem, ipsum dolor sit amet consectetur adipisicing elit.
Enim nulla tempore facilis, harum provident porro, delectus tenetur commodi culpa eius veritatis.
Reiciendis ea exercitationem quasi reprehenderit pariatur quos. Repellat, ratione!
Lorem, ipsum dolor sit amet consectetur adipisicing elit.
Enim nulla tempore facilis, harum provident porro, delectus tenetur commodi culpa eius veritatis.
Reiciendis ea exercitationem quasi reprehenderit pariatur quos. Repellat, ratione!
</div>
</body>
</html>
06-样式继承
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
a {
font-size: 20px;
text-decoration: none;
color: blue;
}
div {
font-size: 50px;
color: aqua;
}
/* css样式的继承性
不是所有样式都继承,只有改变之后对布局无影响的样式,才会继承
a链接最好在自身更改样式
*/
</style>
</head>
<body>
<div>
Lorem ipsum dolor sit amet consectetur adipisicing elit<br />
<span>Voluptates reprehenderit quisquam, incidunt itaque delectus</span><br />
<a href="#">sequi officiis dolorem ut, recusandae veniam unde fugit quam obcaecati?</a>
</div>
</body>
</html>
07-解决padding影响盒子大小问题
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div {
width: 300px;
height: 300px;
background-color: aquamarine;
padding: 40px;
border: 2px solid red;
box-sizing: border-box;
}
</style>
</head>
<body>
<div>
Lorem, ipsum dolor sit amet consectetur
Enim nulla tempore facilis, harum provident
Reiciendis ea exercitationem quasi reprehenderit
Lorem, ipsum dolor sit amet consectetur adipisicing.
Enim nulla tempore facilis, harum provident porro
Reiciendis ea exercitationem quasi reprehenderit
</div>
</body>
</html>
08-flex布局
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.father {
width: 800px;
height: 400px;
background-color: aqua;
display: flex;
/* 排列方式 */
/* column column-reverse row row-reverse
垂直排 反向垂直排 水平排 反向水平排 */
flex-direction: row;
/* 让flex布局变为多行 */
/* wrap nowrap */
flex-wrap: wrap;
/* 主轴上的布局 */
/* center end space-around space-between space-evenly */
justify-content: end;
/* 侧轴上的布局 */
/* start center end */
/* align-items 设置单行的 */
align-items: start;
/* align-content 设置多行的 */
align-content:center;
}
.son {
width: 100px;
height: 100px;
background-color: blue;
}
</style>
</head>
<body>
<div class="father">
<div class="son">1</div>
<div class="son">2</div>
<div class="son">3</div>
<div class="son">4</div>
<div class="son">4</div>
<div class="son">4</div>
<div class="son">4</div>
<div class="son">4</div>
</div>
</body>
</html>
09-flex
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.father {
display: flex;
width: 400px;
height: 400px;
background-color: aqua;
}
.son {
width: 200px;
background-color: blue;
}
.son1 {
flex: 1;
}
.son2 {
/* order 值越小,排列在越前面 */
order: -2;
}
</style>
</head>
<body>
<div class="father">
<div class="son1 son">1</div>
<div class="son2 son">2</div>
</div>
</body>
</html>
10-定位补充
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.father {
position: relative;
width: 500px;
height: 500px;
background-color: red;
}
.son {
width: 100px;
height: 100px;
}
.son1 {
position: absolute;
/* z-index 定位中显示优先级 */
z-index: 2;
top: 100px;
left: 50px;
background-color: aquamarine;
}
.son2 {
position: absolute;
z-index: 1;
top: 110px;
left: 80px;
background-color: blanchedalmond;
}
</style>
</head>
<body>
<div class="father">
<div class="son1 son"></div>
<div class="son2 son"></div>
</div>
</body>
</html>
11-小米布局练习
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.goods {
display: flex;
width: 1240px;
height: 600px;
}
.left {
width: 230px;
height: 600px;
background-color:aqua;
}
li {
width: 230px;
height: 275px;
list-style: none;
background-color: blanchedalmond;
}
.right {
width: 990px;
height: 700px;
list-style: none;
}
.right ul {
margin-top: 0;
display: flex;
width: 990px;
height: 600px;
flex-wrap: wrap;
justify-content: space-between;
align-content: space-between;
}
</style>
</head>
<body>
<div class="goods">
<div class="left"></div>
<div class="right">
<ul>
<li>
<a href="#">
</a>
</li>
<li>
<a href="#">
</a>
</li>
<li>
<a href="#">
</a>
</li>
<li>
<a href="#">
</a>
</li>
<li>
<a href="#">
</a>
</li>
<li>
<a href="#">
</a>
</li>
<li>
<a href="#">
</a>
</li>
<li>
<a href="#">
</a>
</li>
</ul>
</div>
</div>
</body>
</html>
12-float讲解
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.father {
width: 1000px;
background-color: aqua;
}
.son {
width: 200px;
height: 200px;
background-color: aquamarine;
}
.son2 {
background-color: black;
float: left;
/* float 浮动,会脱离文本流 不在保留原位置 */
/* 会造成在其下方的兄弟元素位置发生变化
当子元素发生浮动时,其父元素的高度发生塌陷 */
}
.son3 {
background-color: blue;
}
</style>
</head>
<body>
<div class="father">
<div class="son son1"></div>
<div class="son son2"></div>
<div class="son son3"></div>
</div>
</body>
</html>
13-float的问题解决方法
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
ul {
height: 300px;
}
ul li {
float: left;
list-style: none;
margin-right: 20px;
}
p {
/* clear 清除浮动 */
clear: both;
}
</style>
</head>
<body>
<ul>
<li>aaaaa</li>
<li>aaaaa</li>
<li>aaaaa</li>
<li>aaaaa</li>
<p>sowapedizjmxowikldxzzd</p>
</ul>
</body>
</html>
14-渐变
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div {
width: 400px;
height: 800px;
background-image: linear-gradient(to right, red,blue,black);
}
</style>
</head>
<body>
<div></div>
</body>
</html>
15-字体图标
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="././."></script>
<style>
/* 进入icon */
.icon {
width: 1em;
height: 1em;
vertical-align: -0.15em;
fill: antiquewhite;
overflow: hidden;
}
</style>
</head>
<body>
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-a-008_hanbaokuaican"></use>
</svg>
</body>
</html>
16-媒体查询
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div {
background-color: aqua;
}
@media screen and (min-width:900px) {
div {
background-color: beige;
}
}
@media only screen and (min-width:320px) and (max-width:700px) {
div {
background-color: blue;
}
}
</style>
</head>
<body>
<div>sdrtdgtybth</div>
</body>
</html>
17-默认外边距
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div>fdsgxjbnvugtfy</div>
</body>
</html>
18-2d转换
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.father {
width: 300px;
height: 300px;
border: 1px solid black;
}
.son {
width: 300px;
height: 300px;
background-color: aqua;
/* 平移 */
transform: translate(80px,40px);
/* X Y */
/* transform: translateX(80px);
transform: translateY(40px); */
/* 旋转 */
/* transform: rotateZ(45deg); */
/* 复合写法 旋转永远放在最后 */
/* transform: translate(10px) rotateZ(45deg); */
/* 缩放 */
/* transform: scale(2); */
/* 扭曲 */
/* transform: skew(45deg); */
}
</style>
</head>
<body>
<div class="father">
<div class="son"></div>
</div>
</body>
</html>
19-3d
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.father {
width: 300px;
height: 300px;
border: 1px solid black;
margin: 100px auto;
/* 开启3d空间 */
transform-style: preserve-3d;
perspective: 800px;
/* perspective-origin: 100px 200px; */
}
.son {
width: 300px;
height: 300px;
background-color: aqua;
/* 旋转 */
transform: rotate3D(1,1,0,45deg);
/* 隐藏背部 */
backface-visibility: hidden;
transform-origin: top;
}
</style>
</head>
<body>
<div class="father">
<div class="son">222222</div>
</div>
</body>
</html>
20-过渡
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.father {
width: 300px;
height: 300px;
border: 1px solid black;
margin: 100px auto;
/* 开启3d空间 */
transform-style: preserve-3d;
perspective: 800px;
}
.son {
transition: all 5s;
width: 300px;
height: 300px;
background-color: aqua;
backface-visibility: hidden;
transform-origin: top;
}
.son:hover {
width: 800px;
transform: rotate3D(1,1,0,45deg);
}
</style>
</head>
<body>
</body>
</html>
21-动画
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
@keyframes myMovie {
from {
width: 200px;
background-color:red;
}
to {
width: 800px;
background-color:antiquewhite;
}
}
/* @keyframes myfirst {
0% {
width: 200px;
background-color:antiquewhite;
}
20% {
width: 400px;
background-color:aqua;
}
80% {
width: 800px;
background-color:blue;
}
100% {
width: 1200px;
background-color: black;
}
} */
div {
width: 200px;
height: 50px;
background-color:aqua;
animation: myMovie 5s infinite;
}
</style>
</head>
<body>
<div>
</div>
</body>
</html>