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

    你可能感兴趣的文章
    PIL.Image、cv2的img、bytes相互转换
    查看>>
    Pillow lacks the JPEG 2000 plugin
    查看>>
    ping 命令的七种用法,看完瞬间成大神
    查看>>
    Pinia:$patch的使用场景
    查看>>
    Pinia:$subscribe()的使用场景
    查看>>
    Pinpoint对Kubernetes关键业务模块进行全链路监控
    查看>>
    Pinterest 大规模缓存集群的架构剖析
    查看>>
    pintos project (2) Project 1 Thread -Mission 1 Code
    查看>>
    PinYin4j库的使用
    查看>>
    PIP
    查看>>
    pip install goose-extractor // SyntaxError: Missing parentheses in call to 'print'
    查看>>
    pip install 出现报asciii码错误的解决
    查看>>
    pip throws TypeError: parse() got an unexpected keyword argument ‘transport_encoding‘ 在尝试安装新软件包时
    查看>>
    pip 下载慢
    查看>>
    pip 安装出现异常
    查看>>
    Pip 安装失败:需要 SSL
    查看>>
    Pip 安装挂起
    查看>>
    pip/pip3更换国内源
    查看>>
    pip3 install PyQt5 --user 失败
    查看>>
    pip3命令全解析:Python3包管理工具的详细使用指南
    查看>>