CSS Day10

10.1 2D位移

属性名:transform

属性值:translateX 水平方向的位移 相对于自身位置移动

translateY 垂直方向的位移 相对于自身位置移动

transform:translate(x,y);

位移和定位搭配使用:
position:absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%);

10.2 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>
         .box {
            width: 100px;
            height: 1px;
            transform: scale(0.1);
            background-color: red;
        }
    </style>
</head>
<body>
    <div class="box"></div>
</body>
</html>
10.3 2D旋转

transform:rotate(60deg);

正值-顺时针,负值-逆时针

10.4 图标的引用

参考阿里巴巴图标库

10.5 精灵图(雪碧图)

图片整合技术

  • 优点:

    1、将多个图片整合成为一张图,浏览器只需要发送一次请求,就可以同时加载多个图片提高访问效率,提高用户的体验度

    2、将多个图片整合成一张图,减少了图片的总大小

  • 精灵图使用步骤:

    1、确定要使用的精灵图

    2、测量每个图片的大小以及图片所在的位置

    3、将精灵图设置为背景图片

    4、使用背景图位置属性展示每个精灵图

案例

<!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;
            text-decoration: none;
            list-style: none;
        }
        .box {
            width: 300px;
            height: 250px;
            margin: 100px auto;
            background-color: rgb(241, 238, 238);
        }
        .wz{
            float: left;
            width: 70px;
            height: 20px;
            margin-top: 15px;
            margin-left: 22px;
            color: rgb(100, 100, 100);
        }
        ul{
            float: left;
            width: 240px;
            height: 180px;
            margin-left: 30px;
            /* background-color: red; */
        }
        li{
            float: left;
            width: 80px;
            height: 90px;
            /* background-color: skyblue; */
        }
        li:first-child{
            background-image: url(images/ToolsIcon.png);
            background-repeat: no-repeat;
            background-position: 27px 28px;
        }
        li:nth-child(2){
            background-image: url(images/ToolsIcon.png);
            background-repeat: no-repeat;
            background-position: 27px -41px;
        }
        li:nth-child(3){
            background-image: url(images/ToolsIcon.png);
            background-repeat: no-repeat;
            background-position: 27px -111px;
        }
        li:nth-child(4){
            background-image: url(images/ToolsIcon.png);
            background-repeat: no-repeat;
            background-position: 27px -182px;
        }
        li:nth-child(5){
            background-image: url(images/ToolsIcon.png);
            background-repeat: no-repeat;
            background-position: 27px -252px;
        }
        li:nth-child(6){
            background-image: url(images/ToolsIcon.png);
            background-repeat: no-repeat;
            background-position: 27px -321px;
        }
        p{
            float: left;
            width: 70px;
            height: 15px;
            margin-top: 60px;
            margin-left: 8px;
            color: gray;
        }
        p:hover{
            color: red;
        }
    </style>
</head>
​
<body>
    <div class="box">
        <p class="wz">职场取经</p>
        <ul>
            <li><p>求职技巧</p></li>
            <li><p>行业薪资</p></li>
            <li><p>简历模板</p></li>
            <li><p>就业指导</p></li>
            <li><p>实习兼职</p></li>
            <li><p>沟通技巧</p></li>
        </ul>
    </div>
</body>
​
</html>

 

相关推荐

  1. 面试经典150题(10-13)

    2024-01-21 20:38:03       34 阅读
  2. <span style='color:red;'>10</span> C++<span style='color:red;'>11</span>

    10 C++11

    2024-01-21 20:38:03      5 阅读
  3. 1210号总结

    2024-01-21 20:38:03       42 阅读
  4. DAY 10 | 1047, (20,150)

    2024-01-21 20:38:03       39 阅读
  5. day10-16:Spring Security

    2024-01-21 20:38:03       8 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-21 20:38:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-21 20:38:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-21 20:38:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-21 20:38:03       18 阅读

热门阅读

  1. Linux设置nginx开机自启动

    2024-01-21 20:38:03       33 阅读
  2. C# 字符串(String)

    2024-01-21 20:38:03       37 阅读
  3. datasets的一些使用技巧

    2024-01-21 20:38:03       33 阅读
  4. 【智驾未来】低代码开发:加速创新交融的利器

    2024-01-21 20:38:03       30 阅读
  5. C# 程序结构

    2024-01-21 20:38:03       30 阅读
  6. 【工业智能】VSB Power Line Fault Detection-chapter2

    2024-01-21 20:38:03       32 阅读
  7. 生产告警JVM内存使用率超过80%告警问题排查

    2024-01-21 20:38:03       34 阅读