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

    你可能感兴趣的文章
    PHP中array_merge和array相加的区别分析
    查看>>
    PHP中Closure::bindTo的用法分析
    查看>>
    php中curl得使用
    查看>>
    PHP中curl特性
    查看>>
    PHP中date时间不对
    查看>>
    PHP中dirname(__FILE__)的意思
    查看>>
    PHP中extract()函数的妙用
    查看>>
    PHP中fileinfo的作用以及怎么开启fileinfo
    查看>>
    PHP中file_get_contents如何带上cookies
    查看>>
    PHP中header的作用
    查看>>
    PHP中implode()和explode()
    查看>>
    PHP中ob系列函数讲解(浏览器缓存技术)
    查看>>
    PHP中serialize和json序列化与反序列化的区别
    查看>>
    Redis事务处理
    查看>>
    php中传值与传引用的区别是什么
    查看>>
    php中使用ajax进行前后端json数据交互
    查看>>
    Redis事务和锁操作
    查看>>
    Redis事务中的watch机制-从实例入手学习
    查看>>
    PHP中如何得到数组的长度
    查看>>
    Redis 集群模式下一个 Master 挂掉后如何选举?
    查看>>