W3css-containers

提供:Dev Guides
移動先:案内検索

W3.CSS-コンテナー

HTML5には次のコンテナ要素があります-

  • <div> -HTMLコンテンツに汎用コンテナを提供します。
  • <header> -ヘッダーセクションを表します。
  • <footer> -フッターセクションを表します。
  • <article> -記事を表します。
  • <section> -さまざまなタイプのセクションの汎用コンテナを提供します。

W3.CSSは、上記のすべてのコンテナをスタイルするためのプライマリクラスとして w3-container を提供します。 W3.CSSには、 w3-borderw3-redw3-tealw3-padding-32 などの他のクラスもあり、コンテナーにさらにスタイリング属性を追加します。

次の例は、さまざまなコンテナをスタイルするためのw3-containerクラスの使用を示しています。

w3css_containers

<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 @finddevguides.COM</p>
      </footer>
   </body>
</html>

結果

結果を確認します。

W3.CSSは、コンテナに非表示/閉じる機能も提供します。 次の例を参照してください-

w3css_hide_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>
      <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>

結果

結果を確認します。