Create a three-bar layout with CSS floats

xiaoxiao2021-03-06  24

The three-column layout is the current most common webline layout. The main page is placed in the middle column, and the two columns on the side places the contents of the navigation link. The basic layout is generally under the title, the three columns occupy the width of the entire page, and finally placed the footer on the bottom of the page, the footer also occupies the entire page width.

Most web designers are familiar with traditional web design technologies, using these technologies to generate a table, create a fixed width layout or "liquid" (it can be automatically extended according to the user browser window width automatically) layout.

Now, we have begun to abandon the table-based layout technology, and many network designers are looking for a way to create a three-column layout from the new paradigm of XHTML tags and CSS formats. The layout of the fixed width from the CSS is not difficult to obtain a fixed width in the CSS; but the liquid layout is a bit difficult. Therefore, this paper introduces a method of obtaining a three-column liquid layout with a CSS FLOAT and CLEAR attribute.

basic method

The basic layout contains five DIVs, namely headings, footers, and three columns. The title and footer occupy the entire page. The left column DIV and right column DIV are fixed widths and are squeezed to the left and right of the browser window with the float attribute. The Chinese bar actually occupies the entire page wide, the contents of the middle bar are "flowing" between the left and right columns. Since the width of the neutral DIV is not fixed, it can make the necessary telescopic according to the change in the browser window. The Padding attribute on the left and right side of the Zhongba DIV ensures that the content is arranged in a neat bar, even when it stretches the bottom of the side (left column or right bar).

An example of a three-column layout

Please see the example of the three column layout in this article. This example uses a bright color to distinguish the layout of each DIV. The following is XHTML code:

CopyRight © 2020 All Rights Reserved
Processed: 0.044, SQL: 9