当前位置: 首页 > news >正文

CSS 网页布局

        网页布局有很多种方式,一般分为以下几个部分:头部区域、菜单导航区域、内容区域、底部区域:

1)、头部区域位于整个网页的顶部,一般用于设置网页的标题或者网页的logo。

<style>

body {

  margin: 0;

}

/* 头部样式 */

.header {

  background-color: #f1f1f1;

  padding: 20px;

  text-align: center;

}

</style>

</head>

<body>

<div class="header">

  <h1>头部区域</h1>

</div>

</body>

2)、菜单导航栏包含一些链接,可以引导用户浏览其他网页:

<style>

* {

  box-sizing: border-box;

}

body {

  margin: 0;

}

/* 头部样式 */

.header {

  background-color: #f1f1f1;

  padding: 20px;

  text-align: center;

}

/* 导航条 */

.topnav {

  overflow: hidden;

  background-color: #333;

}

/* 导航链接 */

.topnav a {

  float: left;

  display: block;

  color: #f2f2f2;

  text-align: center;

  padding: 14px 16px;

  text-decoration: none;

}

/* 链接 - 修改颜色 */

.topnav a:hover {

  background-color: #ddd;

  color: black;

}

</style>

</head>

<body>

<div class="header">

  <h1>头部区域</h1>

</div>

<div class="topnav">

  <a href="#">主页</a>

  <a href="#">产品</a>

  <a href="#">关于</a>

</div>

3)、内容区域一般有2种形式;1列(一般用于移动端);2列(一般用于平板设备);3列(一般用于PC设备)。

<style>

* {

  box-sizing: border-box;

}

body {

  margin: 0;

}

/* 头部样式 */

.header {

  background-color: #f1f1f1;

  padding: 20px;

  text-align: center;

}

/* 导航条 */

.topnav {

  overflow: hidden;

  background-color: #333;

}

/* 导航链接 */

.topnav a {

  float: left;

  display: block;

  color: #f2f2f2;

  text-align: center;

  padding: 14px 16px;

  text-decoration: none;

}

/* 链接 - 修改颜色 */

.topnav a:hover {

  background-color: #ddd;

  color: black;

}

/* 创建三个相等的列 */

.column {

  float: left;

  width: 33.33%;

}

/* 列后清除浮动 */

.row:after {

  content: "";

  display: table;

  clear: both;

}

/* 响应式布局 - 小于 600 px 时改为上下布局 */

@media screen and (max-width: 600px) {

  .column {

    width: 100%;

  }

}

</style>

4)、底部区域在网页的最下方,一般包含版权信息和联系方式等:

/* 底部样式 */

.footer {

  background-color: #f1f1f1;

  padding: 10px;

  text-align: center;

}

http://www.lryc.cn/news/222210.html

相关文章:

  • 智慧燃气管网监测系统功能简要介绍
  • 深度解析:如何开发一对一交友App的关键要素和流程
  • ClickHouse 学习之从高级到监控以及备份(二)
  • 「随笔」IT行业哪个方向比较好就业
  • Halcon WPF 开发学习笔记(0):开篇介绍
  • SLAM中求导相关的公式总结
  • 在微信小程序中怎么做投票活动
  • 如何使用 NFTScan NFT API 在 Arbitrum 网络上开发 Web3 应用
  • 线上问题排查方法
  • 智能柜+MRO:制造业中的自动售货机
  • flutter笔记:骨架化加载器
  • 关于视频封装格式和视频编码格式的简介
  • npm发布自己的包
  • 【漏洞复现】weblogic-10.3.6-‘wls-wsat‘-XMLDecoder反序列化(CVE-2017-10271)
  • CRM中的销售机会管理是什么?三个步骤帮你创建销售渠道
  • X(原Twitter)怎么发推文最有效?技巧分享
  • Ionic 模块组件的理解
  • sql:1对多获取最新一条数据
  • CDN加速技术:降低企业云服务成本的有效利用
  • 设计模式——享元模式(Flyweight Pattern)+ Spring相关源码
  • vue3中el-tree设置默认选中节点和展开节点
  • 软件测试需求分析是什么?为什么需要进行测试需求分析?
  • GreenPlum简介
  • HTML和CSS入门学习
  • 轻量封装WebGPU渲染系统示例<17>- 使用GPU Compute之元胞自动机(源码)
  • fmx windows 下 制作无边框窗口最小化最大化并鼠标可拖移窗口
  • 【Python】11 Conda常用命令
  • 5G边缘计算网关 是什么?
  • mac电脑系统清理软件CleanMyMac X2024破解版下载
  • 19 款Agent产品工具合集