移动WEB开发之rem布局--苏宁首页案例制作(技术方案1)
创始人
2024-03-21 20:05:43

案例:苏宁网移动端首页

访问地址:苏宁易购(Suning.com)-家电家装成套购,专注服务省心购!

 1. 技术选型

方案:我们采取单独制作移动页面方案

技术:布局采取rem适配布局(less + rem + 媒体查询)

设计图: 本设计图采用 750px 设计尺寸

2. 搭建相关文件夹结构

3. 设置视口标签以及引入初始化样式 


4. 设置公共common.less文件

1. 新建common.less 设置好最常见的屏幕尺寸,利用媒体查询设置不同的html字体大小,因为除了首页其他页面也需要

2. 我们关心的尺寸有 320px、360px、375px、384px、400px、414px、424px、480px、540px、720px、750px

3. 划分的份数我们定为 15等份

4. 因为我们pc端也可以打开我们苏宁移动端首页,我们默认html字体大小为 50px,注意这句话写到最上面

5. 新建index.less文件

1. 新建index.less 这里面写首页的样式

2. 将刚才设置好的 common.less 引入到index.less里面 语法如下:

// 在 index.less 中导入 common.less 文件
@import “common”

3. 生成index.css 引入到 index.html 里

6. body样式

body {
min-width: 320px;
width:15rem;
margin: 0 auto;
line-height: 1.5;
font-family: Arial,Helvetica;
background: #F2F2F2;
}

search-content模块制作 

 search模块制作

banner和广告模块制作

 nav部分制作

苏宁的做法是,把它固定死,宽度750px分5份

 

// 首页的样式less文件
@import url(common.less);
// @import 导入的意思 可以把一个样式文件导入到另外一个样式文件中
body {min-width: 320px;width:15rem;margin: 0 auto;line-height: 1.5;font-family: Arial,Helvetica;background: #F2F2F2;
}
// 页面元素rem计算公式:页面元素的px/html字体大小
// search-content
// 这里的50,是我们在750的页面下设置的
@baseFont:50;
.search-content{position: fixed;top: 0;left: 50%;transform: translateX(-50%);width: 15rem;height: (88rem/@baseFont);background-color: #FFc001;display: flex;.classify{width: (44rem/@baseFont);height: (70rem/@baseFont);background: url(../images/classify.png) no-repeat;// 背景缩放background-size:(44rem/@baseFont) (70rem/@baseFont);margin: (11rem/@baseFont) (25rem/@baseFont) (7rem/@baseFont) (24rem/@baseFont);}.search{flex: 1;input{outline: none;width: 100%;border: 0;height: (66rem/@baseFont);border-radius: (33rem/@baseFont);background-color: #fff2cc;margin-top: (12rem/@baseFont);font-size: (25rem/@baseFont);padding-left: (55rem/@baseFont);color: #757575;}}.login{width: (75rem/@baseFont);height: (70rem/@baseFont);line-height: (70rem/@baseFont);margin: (10rem/@baseFont);font-size: (25rem/@baseFont);text-align: center;color: #fff;}
}   // banner
.banner{width: (750rem/@baseFont);height: (368rem/@baseFont);img{width: 100%;height: 100%;}
}
// ad
.ad{display: flex;a{flex: 1;img{width: 100%;}}
}
// nav
nav{width: (750rem/@baseFont);a{width: (150rem/@baseFont);height: (140rem/@baseFont);float: left;text-align: center;}img{// margin值不能用在行内或者行内块去设置居中,另外,没有设置宽度的块级元素也不可以设置display: block;width: (82rem/@baseFont);height: (82rem/@baseFont);margin: (10rem/@baseFont) auto 0;}span{font-size: (25rem/@baseFont);color: #333;}
}

 



Document

相关内容

热门资讯

深圳平面设计就业前景 深圳平面... 平面设计与商业活动紧密结合,在国内的就业范围非常广泛,与各行业密切相关,同时也是其他各设计门类(诸如...
中国戏曲学院戏剧影视文学专业一... 考试时间:2月10日上午9:00-11:00——英语笔试  2月10日下午13:30-15:30——...
关于最新或2023(历届)12... 各位考生: 最新或2023(历届)12月份(含)之前全国专业技术人员计算机应用能力考试...
宁夏大学最新或2023(历届)... 记者从宁夏大学招生办获悉,最新或2023(历届),宁夏大学将面向全国招收运动训练、武术与民族传统体育...
宁夏大学高水平运动员招生项目时...  2月20日报名结束3月4、5日在宁夏大学进行专项测试  日前,记者从宁夏大学获悉,为提高宁夏大学体...