During webpage layout, text and images are usually centered for the sake of appearance. It is difficult to use Div to achieve the same effect after using table layout. In fact, it is not difficult for the meeting, as long as the following section Code You can easily center the DIV, and in the example, I have implemented two sidebar, which can basically meet the overall layout needs of most web pages. 1 <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
2 < Html Xmlns = "Http://www.w3.org/1999/xhtml" Dir = "LTR" >
3 < Head Profile = "Http://gmpg.org/xfn/11" >
4 </ Head >
5 < Body >
6 < Div Style = "Position: relative; margin-left: auto; margin-Right: auto; width: 786px; Background-color: Purple ;" >
7 < Div Style = "Width: 500px; float: Right" > Content </ Div >
8 < Div Style = "Background-color: yellow; width: 200px" > Sidebar </ Div >
9 < Div Style = "Background-color: Blue; width: 200px" > Sidebar </ Div >
10 </ Div >
11 </ Body >
12 </ Html >
Download code files