W3.CSS-容器

HTML5具有以下容器元素-

  • <div> -为HTML内容提供通用容器。
  • <header> -表示标题部分。
  • <footer> -表示页脚部分。
  • <article> -代表文章。
  • <section> -为各种类型的节提供通用容器。

W3.CSS将w3-container作为主要类来为所有上述容器设置样式。W3.CSS还具有其他类,例如w3-borderw3-redw3-tealw3-padding-32,以向容器添加更多样式属性。

以下示例展示了如何使用w3-container类来设置各种容器的样式。

<html>
   <head>
      <title>The W3.CSS Containers</title>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://www.w3schools.com/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还为容器提供隐藏/关闭功能。请参阅以下示例:

<html>
   <head>
      <title>The W3.CSS Containers</title>
      <meta name = "viewport" content="width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://www.w3schools.com/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>

作者:terry,如若转载,请注明出处:https://www.web176.com/w3css/946.html

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2020年11月3日 下午3:11
下一篇 2020年11月3日 下午3:15

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注