移动web开发01

字体图标

目的:使用字体图标技巧实现网页中简洁的图标效果。
在使用前首先要下载字体包:

  • 登录(新浪微博) → 选择图标库 → 选择图标,加入购物车 → 购物车 → 添加至项目 → 下载至本地

使用字体图标:
Unicode编码:在这里插入图片描述

类名:
在这里插入图片描述

注意:在使用类名时前面的点不用复制上去。

Unicode编码,代码如下:

    <style>
        span {
            font-family: 'iconfont';
        }
    </style>
<span>&#xe6f8</span>

类名,代码如下:
先要引用下载好的字体包

<link rel="stylesheet" href="iconfont.css文件的路径">
    <style>
        .iconfont {
            font-size: 60px;
        }
    </style>
<i class="iconfont icon-favorites-fill"></i>

注意:i 标签内的 iconfont 是必须要写上的,后面空格跟上复制下来的图标类名。

平面转换

目标:实现元素的位移、旋转、缩放等效果。
平面转换的属性:transform

1. 位移
transform: translate(水平移动距离, 垂直移动距离);

    <style>
        .father {
            width: 500px;height: 300px;margin: 100% auto;border: 1px solid #000;
        }
        .son {
            width: 200px;height: 100px;background-color: pink;transition: all 0.5s;
        }
        .father:hover .son {
            transform: translate(100px,50px);
            /* 百分比:盒子自身移动的百分比 */
            transform: translate(100%,50px);
            transform: translate(-100px,50px);
            /* 只给出一个值表示x移动距离 */
            transform: translate(100px);
        }
    </style>

位移-绝对定位居中

    <style>
        .father {
            position: relative;
            width: 500px;
            height: 300px;
            margin: 100px auto;
            border: 1px solid #000;
        }
        .son {
            position: absolute;
            left: 50%;
            top: 50%;
            /* 方法一 */
            /* margin-top: -50px;
            margin-left: -100px; */

            /* 方法二 */
            transform: translate(-50%,-50%);

            width: 200px;
            height: 100px;
            background-color: pink;
        }

    </style>

2. 旋转
transform: rotate(角度)
角度的单位是deg
取值为正时,时针旋转;取值为负时,时针旋转。

    <style>
        img {
            width: 250px;
            transition: all 2s;
        }
        img:hover {
            /* 顺时针 */
            transform: rotate(360deg);
            /* 逆时针 */
            transform: rotate(-360deg);
        }
    </style>

多重旋转
使用transform复合属性实现

 transform: translate(600px) rotate(360deg);

3. 缩放
transform: scale(缩放倍数);

    <style>
        .box {
            width: 300px;height: 210px;margin: 100px auto;background-color: black;
        }
        .box img {
            width: 100%;
            transition: all .5s;
        }
        .box:hover img {
            /* width: 150%; */
            transform: scale(0.8);
        }
    </style>

渐变

渐变是多个颜色逐渐变化的视觉效果,一般用于设置盒子的背景。
使用background-image属性实现

    <style>
        .box {
            width: 300px;
            height: 200px;
            background-image: linear-gradient(
                transparent,rgba(0,0,0, .4)
            );
        }
    </style>

小编开始写不久,如有错误可在评论区留言及时更正哦~
欢迎大家留言!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值