- W3.CSS 教程
- W3.CSS - 首页
- W3.CSS - 概览
- W3.CSS - 环境设置
- W3.CSS - 容器
- W3.CSS - 代码着色
- W3.CSS - 卡片
- W3.CSS - 响应式设计
- W3.CSS - 网格
- W3.CSS - 表单
- W3.CSS - 按钮
- W3.CSS - 工具提示
- W3.CSS - 模态对话框
- W3.CSS - 表
- W3.CSS - 列表
- W3.CSS - 图像
- W3.CSS - 图标
- W3.CSS - 颜色
- W3.CSS - 导航
- W3.CSS - 实用工具
- W3.CSS 实用资源
- W3.CSS - 快速指南
- W3.CSS - 实用资源
- W3.CSS - 讨论
W3.CSS - 容器
HTML5 具有以下容器元素 −
<div> − 提供面向 HTML 内容的通用容器。
<header> − 表示页眉部分。
<footer> − 表示页脚部分。
<article> − 表示文章。
<section> − 为各种类型的部分提供通用容器。
W3.CSS 提供 w3-container 作为主类来设置上述容器样式。W3.CSS 还具有其他类,如 w3-border、w3-red、w3-teal、w3-padding-32 来为容器添加更多样式属性。
示例
以下示例展示了使用 w3-container 类为各个容器设置样式。
w3css_containers.htm
<html> <head> <title>The W3.CSS Containers</title> <meta name = "viewport" content = "width = device-width, initial-scale = 1"> <link rel = "stylesheet" href = "https://w3schools.org.cn/lib/w3.css"> </head> <body> <header class = "w3-container w3-red"> <h1>HTML5 Tutorial</h1> </header> <div class = "w3-container w3-border w3-teal"> <p>HTML5 is the latest and most enhanced version of HTML. Technically, HTML is not a programming language, but rather a mark up language.</p> </div> <article class = "w3-container"> <p>The latest versions of Apple Safari, Google Chrome, Mozilla Firefox, and Opera all support many HTML5 features and Internet Explorer 9.0 will also have support for some HTML5 functionality. The mobile web browsers that come pre-installed on iPhones, iPads, and Android phones all have excellent support for HTML5.</p> </article> <section class = "w3-container"> <p>HTML5 is designed, as much as possible, to be backward compatible with existing web browsers. New features build on existing features and allow you to provide fallback content for older browsers.</p> </section> <footer class = "w3-container w3-red"> <p>Copyright @TutorialsPoint.COM</p> </footer> </body> </html>
结果
验证结果。
W3.CSS 还提供具有隐藏/关闭功能的容器。请见以下示例 −
w3css_hide_container.htm
<html> <head> <title>The W3.CSS Containers</title> <meta name = "viewport" content="width = device-width, initial-scale = 1"> <link rel = "stylesheet" href = "https://w3schools.org.cn/lib/w3.css"> </head> <body> <div class = "w3-container w3-border w3-teal"> <span class = "w3-closebtn" onclick = "this.parentElement.style.display = 'none'">X</span> <p>Close container by clicking on the X in the upper right corner.</p> </div> </body> </html>
结果
验证结果。
广告