博客
关于我
伸缩布局小练习
阅读量: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 Web自动化测试开发环境搭建(附安装包与虚拟机环境)
    查看>>
    python win32api键盘_Python win32api.keybd_event模拟键盘输入
    查看>>
    python Windows显示当前鼠标坐标
    查看>>
    python Workbook 表格宽度
    查看>>
    python | flanker,一个神奇的 Python 库!
    查看>>
    python | flower,一个强大的 Python 库!
    查看>>
    python | funcy,一个超强的 提供函数式编程工具 Python 库!
    查看>>
    python | ggplot,一个超强的 Python 库!
    查看>>
    python | grab,一个强大的 Python 库!
    查看>>
    python | rich,一个无敌的 Python 库!
    查看>>
    python | rq,一个无敌的 关于Redis 的Python 库!
    查看>>
    python | unoconv,一个超厉害的 Python 库!
    查看>>
    python | urllib3,一个超强的 Python 库!
    查看>>
    python | webassets,一个超强的 Python 库!
    查看>>
    python | werkzeug,一个不可思议的 Python 库!
    查看>>
    python | xlsxwriter,一个实用的 Python 库!
    查看>>
    python | xlwings,一个非常实用的 Excel 相关的 Python 库!
    查看>>
    python | 一文看懂Python闭包机制与变量作用域规则
    查看>>
    python读取含中文的json
    查看>>
    python | 如何用Python锁避免并发错误?
    查看>>