博客
关于我
伸缩布局小练习
阅读量:225 次
发布时间:2019-03-01

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

移动端显示需要加"视口",使当前页面宽度等于设备宽度。元标签 viewport 的设置至关重要,能够确保页面在不同设备上以最佳比例显示。以下是整体布局的默认样式:

  • 全局样式:
    margin: 0;
    padding: 0;
    list-style: none;

html元素默认字体大小为 10px;

body背景颜色为 #e8e8e8,字体大小为 1.6rem。

页面内容主要由以下部分组成:

  • 头部区域:

    使用 Flexbox 布局,包含多个导航选项,如"推荐"、"热点"、"视频"、"娱乐"、"军事"等,样式为 flex布局,子项均为 flex: 1。

  • 主内容区域:

    包含两种类型的单元格:cell1 和 cell2。

    • cell1:以 Flexbox 为基础布局,左右两侧分别放置三个图片容器和文字内容。
    • cell2:左右分割,左侧为图片容器,右侧为文字内容区域,右侧子项采用 flex 列布局,分别占据 2/6 和 4/6 的比例。
  • 内容单元格样式:

    cell1 和 cell2 具有共同的样式,包括内边框、背景颜色及 padding。其中 cell1 中心区域采用 Flexbox 列布局,子项均占据 1/3 的比例。cell2 的右侧区域则采用 flex 行布局,包含文字内容和图片。

  • 以下是部分样式定义:

    • 导航栏样式:

      .bd-header span { padding: 0.3rem; }
      .bd-header span.current { color: #cccccc; }

    • 内容样式:

      .bd-content { margin-top: 5rem; }
      .bd-content .cell1, .cell2 { padding: 0.5rem; background-color: #ffffff; border-bottom: 0.1rem solid #e8e8e8; }
      .bd-content .cell1-center { display: flex; justify-content: space-around; align-items: center; }
      .bd-content .cell1-center div { flex: 1; padding: 1rem; }
      .bd-content .cell1-center div img { width: 100%; }
      .bd-content .cell2 { display: flex; }
      .bd-content .cell2-left { flex: 2; }
      .bd-content .cell2-left img { width: 100%; height: 100%; }
      .bd-content .cell2-right { flex: 4; display: flex; flex-direction: column; margin-left: 0.1rem; }
      .bd-content .cell2-right p:first-child { flex: 1; height: 2rem; line-height: 2.5rem; overflow: hidden; }

    整体布局效果如附图所示,页面内容通过 Flexbox 和 Grid 布局实现响应式设计,确保不同设备上都能良好显示。

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

    你可能感兴趣的文章
    python | 一文看懂Python闭包机制与变量作用域规则
    查看>>
    python读取含中文的json
    查看>>
    python | 如何用Python锁避免并发错误?
    查看>>
    python | 提升代码迭代速度的Python重载方法
    查看>>
    python | 深入理解Python并发编程中的GIL限制与解决方案
    查看>>
    Python | 爬虫实战——亚马逊搜索页监控(附详细源码)
    查看>>
    python | 高效使用Python工具自动生成模块文档的秘诀
    查看>>
    python 一个list去除另一个list中的值
    查看>>
    python 三大框架的 介绍。
    查看>>
    Python 下载的 11 种姿势,一种比一种高级!
    查看>>
    python读取一个文件夹下所有图片_初学Python-找出文件夹下的所有图片
    查看>>
    Python 中 3 个不可思议的返回功能
    查看>>
    python 中 dict 的另一种用法
    查看>>
    Python 中 PIL 读取图片出现异常旋转的解决方法
    查看>>
    python读取word表格内容(1)
    查看>>
    python 中os.path.join 双斜杠的解决办法
    查看>>
    python 中PIL.Image和OpenCV图像格式相互转换
    查看>>
    Python 中Semaphore 信号量对象、Event事件、Condition
    查看>>
    python 中with的使用及样例
    查看>>
    python读取wav文件并播放[pyaudio/wave]
    查看>>