博客
关于我
伸缩布局小练习
阅读量: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/

    你可能感兴趣的文章
    Qualitor processVariavel.php 未授权命令注入漏洞复现(CVE-2023-47253)
    查看>>
    poj 1151 (未完成) 扫描线 线段树 离散化
    查看>>
    POJ 1151 / HDU 1542 Atlantis 线段树求矩形面积并
    查看>>
    poj 1163 数塔
    查看>>
    POJ 1177 Picture(线段树:扫描线求轮廓周长)
    查看>>
    Qualitor checkAcesso.php 任意文件上传漏洞复现(CVE-2024-44849)
    查看>>
    POJ 1182 食物链(并查集拆点)
    查看>>
    POJ 1185 炮兵阵地 (状态压缩DP)
    查看>>
    POJ 1195 Mobile phones
    查看>>
    POJ 1228 Grandpa's Estate (稳定凸包)
    查看>>
    poj 1236(强连通分量分解模板题)
    查看>>
    poj 1258 Agri-Net
    查看>>
    quagga 和 zebos
    查看>>
    poj 1286 Necklace of Beads
    查看>>
    POJ 1321 棋盘问题
    查看>>
    poj 1321(回溯)
    查看>>
    Qt高级——Qt元对象系统源码解析
    查看>>
    qt调用vs2008编写的dll动态库(隐式调用)
    查看>>
    Qt读取注册表默认值
    查看>>
    poj 1679 判断MST是不是唯一的 (次小生成树)
    查看>>