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>
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; }
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>
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; }
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