0076 移动端常见布局,二倍精灵图做法

1.移动端单独制作
  • 流式布局(百分比布局)【百分比%,是跟父元素相对的。】
  • flex 弹性布局(强烈推荐)
  • less+rem+媒体查询布局
  • 混合布局
2.响应式
  • 媒体查询
  • bootstarp

流式布局:

流式布局,就是百分比布局,也称非固定像素布局。

通过盒子的宽度设置成百分比来根据屏幕的宽度来进行伸缩,不受固定像素的限制,内容向两侧填充。

流式布局方式是移动web开发使用的比较常见的布局方式。

demo:流式布局
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        section {
            width: 100%;
            max-width: 980px;
            min-width: 320px;
            margin: 0 auto;
        }
        
        section div {
            float: left;
            width: 50%;
            height: 400px;
        }
        
        section div:nth-child(1) {
            background-color: pink;
        }
        
        section div:nth-child(2) {
            background-color: purple;
        }
    </style>
</head>

<body>
    <section>
        <div></div>
        <div></div>
    </section>
</body>

</html>

6.二倍精灵图做法

  • 在firework里面,把精灵图等比例缩放为原来的一半

  • 之后根据大小,测量坐标

  • 注意,代码里面background-size也要写: 精灵图原来宽度的一半

  • 不要保存firework里缩放的图,否则会修改原图

.sou {
    position: absolute;
    top: 8px;
    left: 50px;
    width: 18px;
    height: 15px;
    background: url(../images/jd-sprites.png) no-repeat -81px 0;
    /* 原图宽度是397px。auto 可以省略。 */
    background-size: 200px auto;
}

posted on 2019-12-31 20:17  冲啊!  阅读(441)  评论(0编辑  收藏  举报

导航