Home > Web Front-end > CSS Tutorial > Create a column layout using CSS

Create a column layout using CSS

WBOY
Release: 2023-08-25 17:41:09
forward
1108 people have browsed it

使用 CSS 创建列布局

To create a column layout,

Set the margins and padding for the entire document as follows

<style>
   <!--
      body {
         margin:9px 9px 0 9px;
         padding:0;
         background:#FFF;
      }
    -->
</style>
Copy after login

Define a yellow column, Later, we attach this rule to -

<style>
  <!--
     #level0 {
         background:#FC0;
     }
   -->
</style>
Copy after login

Now let us define another partition inside level0 -

<style>
   <!--
      #level1 {
         margin-left:143px;
         padding-left:9px;
         background:#FFF;
      }
   -->
</style>
Copy after login

Nest one more partition, the complete code is as follows-

<style>
 
   body {
      margin:9px 9px 0 9px;
      padding:0;
      background:#FFF;
   }

   #level0 {background:#FC0;}
   #level1 {
      margin-left:143px;
      padding-left:9px;
      background:#FFF;
   }

   #level2 {background:#FFF3AC;}
   #level3 {
      margin-right:143px;
      padding-right:9px;
      background:#FFF;
   }

   #main {background:#CCC;}
</style>
 
<body>
 
   <div id="level0">
      <div id="level1">
         <div id="level2">
            <div id="level3">
               <div id="main">
                   Final Content goes here...
               </div>
            </div>
         </div>
      </div>
   </div>

</body>
Copy after login

The above is the detailed content of Create a column layout using CSS. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template