html从零开始8:css3新特性、动画、媒体查询、雪碧图、字体图标【搬代码】

css3新特性

1

<!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>
        div{
            width: 200px;
            height: 200px;
            background-color: aqua;
            position: relative;
            border-radius: 20px;/*圆角属性,100%就变成圆形了*/
            left: 50px;
            top: 100px;
        }

    </style>
</head>
<body>
    <div></div>
</body>
</html>

2

两个值
border-radius: 50px 5px;

3
阴影
4

<!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>
        div{
            width: 200px;
            height: 200px;
            background-color: aqua;
            position: relative;
            border-radius: 50px 5px;/*圆角属性*/
            left: 50px;
            top: 100px;
        }
        .box1{
            width: 200px;
            height: 200px;
            background-color: blueviolet;
            margin: 0 auto;/*将div放到中间,左右空袭平均分配*/
            box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.5);/*px也可以变成负数,那就是对角方向变成阴影*/
        }
    </style>
</head>
<body>
    <div></div>
    <div class="box1"></div>
</body>
</html>

5

动画

6
7
8
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></title>
    <style>
        div{
            width: 200px;
            height: 200px;
            background-color: brown;
            animation: myAnmin 3s linear 0s infinite ;
            /* animation: name duration timing-function delay iteration-count direction fill-mode;
                
            */
        }
        /*鼠标滑倒该元素上就触发*/
        div:hover{
            /* background-color: blanchedalmond; */
            animation-play-state: paused;
        }
        @keyframes myAnmin {
            0%{
                width: 100px;
                height: 200px;
                background-color: antiquewhite;
            }
            25%{
                width: 300px;
                height: 200px;
                background-color: aqua;
            }
            50%{
                width: 600px;
                height: 200px;
                background-color: bisque;
            }
            75%{
                width: 1000px;
                height: 200px;
                background-color: black;
            }
            100%{
                background-color: blue;
            }
            75%{
                width: 1000px;
                height: 200px;
                background-color: black;
            }
            50%{
                width: 600px;
                height: 200px;
                background-color: bisque;
            }
            25%{
                width: 300px;
                height: 200px;
                background-color: aqua;
            }
        }
    </style>
</head>
<body>

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

10
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></title>
    <style>
        .box{
            width: 500px;
            height: 400px;
            margin: 40px auto;
            background-color: cadetblue;
            border-radius: 5px;
            box-shadow: 0 1px 2px;
            animation: breathe 2.7s ease-in-out infinite alternate;
        }
        @keyframes breathe {
            0%{
                opacity: 0.2;
                box-shadow: 0 1px 2px rgba(255, 255, 255, 0.1);
            }
            50%{
                opacity: 0.5;
                box-shadow: 0 1px 2px rgba(18, 190, 84, 0.76);
            }
            100%{
                opacity: 1;
                box-shadow: 0 1px 30px rgba(59, 255, 255, 1);
            }
        }
    </style>
</head>
<body>
    <div class="box"></div>
</body>
</html>

12
13

媒体查询

14
15

<!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>
        .box1{
            width: 300px;
            height: 300px;
        }
        @media screen and (max-width: 768px) {/*max-width: 768px屏幕宽度768手机*/
            .box1{
                background-color: aqua;
            }
            .p1{
                display: none;
            }
            .p2{
                display: none;
            }
        }
        @media screen and (min-width: 768px) and (max-width: 996px) {/*max-width: 768px屏幕宽度996平板*/
            .box1{
                background-color: blue;
            }
            .p1{
                display: none;
            }
            .p2{
                display: block;/*block显示,none不显示*/
            }
        }
        @media screen and (min-width:996px) {/*max-width: 768px屏幕宽度996电脑*/
            .box1{
                background-color: brown;
            }
            .p1{
                display: block;
            }
            .p2{
                display: block;/*block显示,none不显示*/
            }

        }
    </style>
</head>
<body>
    <div class="box1"></div>
    <p class="p1">嘎嘎嘎</p>
    <p class="p2">哈哈哈</p>
</body>
</html>

图1
16
2
17
3
18

雪碧图

在这里插入图片描述
19

<!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>
        .icon{
            display: block;/*block把一个行内元素变化成一个块级元素;inline变成一个行内元素*/
            width: 70px;
            height: 70px;
            background-image: url(4.jpg);
            border: 1px solid red;
            background-position: -26px -30px;/*参数是xy轴*/
        }
        .icon2{
            display: block;/*block把一个行内元素变化成一个块级元素;inline变成一个行内元素*/
            width: 70px;
            height: 70px;
            background-image: url(4.jpg);
            border: 1px solid red;
            background-position: -26px -140px;/*参数是xy轴*/
        }
    </style>
</head>
<body>
    <span class="icon"></span>
    <span class="icon2"></span>
</body>
</html>

20

字体图标

21
22
下载可以使用的图标代码,iconfont.cn
23
24

<!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">
    <link rel="stylesheet" href="./font/iconfont.css">
    <title></title>
    <style>
        .icon{
            display: block;/*block把一个行内元素变化成一个块级元素;inline变成一个行内元素*/
            width: 70px;
            height: 70px;
            background-image: url(4.jpg);
            border: 1px solid red;
            background-position: -26px -30px;/*参数是xy轴*/
        }
        .icon2{
            display: block;/*block把一个行内元素变化成一个块级元素;inline变成一个行内元素*/
            width: 70px;
            height: 70px;
            background-image: url(4.jpg);
            border: 1px solid red;
            background-position: -26px -140px;/*参数是xy轴*/
        }
        .xing{
            font-size: 40px;
            color: brown;/*color可以设置图标颜色*/
        }
    </style>
</head>
<body>
    <span class="icon"></span>
    <span class="icon2"></span>
    <span class="iconfont icon-xing xing"></span>
</body>
</html>

25

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值