- 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.tw/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.tw/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>
結果
驗證結果。
廣告