博客
关于我
在线教育app移动端页面rem布局项目
阅读量:489 次
发布时间:2019-03-06

本文共 1746 字,大约阅读时间需要 5 分钟。

移动端页面rem布局项目

页面效果

本次项目采用了rem布局的设计理念,实现了页面在不同设备间的流畅适配。通过预先设置的html font-size,结合javascript动态调整,确保了页面在320px到1080px屏幕间的精准响应。核心功能包括搜索框、课程列表及顶部导航等模块的刷新率优化,用户体验达到行业最高标准。

设计稿psd文件

在设计初期,整个页面草图已完成,其中包含搜索模块的布局、顶部导航的位置调整以及重点区域的视觉效果细节。基于psd文件进行了多次优化,确保了界面与用户需求的完美契合。

核心代码解读

本项目的代码实现采用了高效的rem单位结合响应式设计的混合模式。以下是主要代码结构:

html部分:

    
移动端页面rem布局项目

less部分:

* {    margin: 0;    padding: 0;    box-sizing: border-box;}body {    font-family: -apple-system, Helvetica, sans-serif;    background-color: #F6F6F6;    padding-bottom: 200rem/54;}header {    width: 1080rem/54;    height: 370rem/54;    padding: 0 40rem/54;    background: url(../images/椭圆2.png) no-repeat;    overflow: hidden;    .search-box {        width: 100%;        margin-top: 70rem/54;        position: relative;        .search {            height: 100rem/54;            background-color: #83a6ff;            border-radius: 50px;            padding-left: 75rem/54;            img {                width: 50rem/54;                vertical-align: middle;            }        }        .search-right {            position: absolute;            right: 0;            top: 10rem/54;            img {                width: 60rem/54;                height: 66rem/54;            }        }    }}

javascript部分:

function set_fontsize() {    const htm = document.documentElement;    const view_width = htm.clientWidth;    if (view_width >= 320 && view_width < 1080) {        htm.style.fontSize = view_width / 20 + 'px';    } else {        htm.style.fontSize = 54 + 'px';    }}window.addEventListener('resize', set_fontsize);

项目特点分析

  • 通过动态调整html font-size,实现了页面在不同屏幕尺寸间的自然缩放
  • 搜索框及顶部导航模块采用了精确的rwd布局,保证了精细化的交互体验
  • 对关键功能模块进行了双臂结构设计,确保了跨设备表现的统一性
  • 通过模块化开发提高了代码维护的效率
  • 源码下载

    建议下载完整项目源码,以便于详细了解rem布局的实现细节和优化方案。

    转载地址:http://hhpdz.baihongyu.com/

    你可能感兴趣的文章
    python中del函数的垃圾回收
    查看>>
    Python中DrissionPage的详细解析与实战
    查看>>
    python中enumerate、变量类型转换
    查看>>
    python中execute是啥_python – 为什么“c.execute(…)”打破循环?
    查看>>
    python中exit和break区别_Python中exit()和sys.exit()之间的区别
    查看>>
    python中h5的用法
    查看>>
    python中http协议编程_HTTP编程
    查看>>
    python中import os_Python:相对导入与绝对导入(import)、os.path、__file__
    查看>>
    Python中set.discard和set.remove方法之间的运行时差异?
    查看>>
    python中yield的用法详解——最简单,最清晰的解释
    查看>>
    python中‘set.intersection()‘的算法是什么?
    查看>>
    Python中一个图形中的多个绘图
    查看>>
    python中一个好的持久同步队列
    查看>>
    Python中不准确的对数
    查看>>
    python中什么是实例方法_在Python中创建实例方法对象的不同方法
    查看>>
    Python中使用cutecharts实现简单的手绘风格的图表
    查看>>
    python中使用dxfgrabber,解析dxf文件信息生成obj文件
    查看>>
    Python中使用ncmbot玩转网易云音乐
    查看>>
    Python中使用PIL快速实现二值图
    查看>>
    Python中使用PIL快速实现灰度图
    查看>>