Home > Web Front-end > HTML Tutorial > The third day of learning Div CSS in ten days [two-column and three-column layout]_html/css_WEB-ITnose

The third day of learning Div CSS in ten days [two-column and three-column layout]_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:30:06
Original
1389 people have browsed it

One or two columns of adaptive width
The following is the common left column fixed and right column adaptive as an example. Because div is a block element, it occupies one row of space by default. To To make the following div run to the right, you need to use css to float it. First create the html code as follows:

<div id="side">此处显示 id "side" 的内容</div><div id="main">此处显示 id "main" 的内容</div>
Copy after login

After the div is created, start creating the css style sheet, the code is as follows:

#side { background: #99FF99; height: 300px; width: 120px; float: left; }#main { background: #99FFFF; height: 300px; width: 70%; margin-left: 120px; }
Copy after login

Then create the #main style. Note that the left margin of #main is set to 120px. The preview results are as follows:

2. Fixed width of two columns
With the previous foundation, it is much easier to fix the width of two columns. You only need to change # The width of main is changed from percentage to fixed value.

3. Two columns with fixed width and center
Two columns with fixed width and center need to be improved on the basis of two columns with fixed width. When learning to center one column with fixed width, we know to let it Centering method, so here you need to add a parent div in addition to these two divs:

<div id="side">此处显示 id "side" 的内容</div><div id="main">此处显示 id "main" 的内容</div>
Copy after login

The css code is as follows:

#content { width:470px; margin:0 auto;}#side { background: #99FF99; height: 300px; width: 120px; float: left; }#main { background: #99FFFF; height: 300px; width: 350px; margin-left: 120px; }
Copy after login

4. Block-level elements (div) and inline elements (span) of xhtml
Block-level element: It is a square, like a paragraph, which occupies one line by default;

Inline element: Also called inline element, as the name suggests, it can only be placed within a line, just like a word, without causing line breaks before and after, and plays an auxiliary role.

General block-level elements such as paragraph

, title

..., list,

source:php.cn
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