First, check the effect:
Code:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" C/>
<Title> CSS partition style: CSS, UL, and Li are used to display news titles in different columns. </title>
<Style type = "text/CSS">
<! --
. Relationnews {width: 660px; font-size: 16px; font-weight: bold; Margin: 0 auto; }
. Relationnewslist {
Font-size: 13px;
Border-top: 1px solid #000000;
Margin: 0 auto;
Padding: 3px 5px 0px 5px;
Width: 660px;
Height: 200px;
}
. Relationnewslist Ul {
Margin: 0 auto;
Padding: 0;
}
. Relationnewslist Li {
Border-bottom: # dddddd 1px solid;
Float: left;
Padding: 5px 0px 0px 10px;
Width: 320px;
Background: url(li.gif) No-repeat 0px 10px;
Height: 22px;
Overflow: hidden;
}
-->
</Style>
</Head>
<Body>
<Div class = "relationnews"> related news: </div>
<Div class =" Relationnewslist ">
<Ul>
<Li> <a target = "_ blank" href = "http://news.sctv.com/gnxw/rdxw/201207/t20120727_1212988.shtml"> Tianjin rainstorm moles residents riding motorboats to the streets </a> </LI>
<Li> <a target = "_ blank" href = "http://leaders.people.com.cn/n/2012/0727/c58278-18609666.html"> 26 people were missing due to Disaster Tolerance in Baoding, Hebei </a> </LI>
<Li> <a target = "_ blank" href = "http://inews.nmgnews.com.cn/system/2012/07/27/010808976.shtml"> five deaths have been killed in heavy rain in Huhhot. </a> </LI>
<Li> <a target = "_ blank" href = "http://news.163.com/12/0726/14/87BK6LG70001124J.html"> Shenzhen has more than 0.11 million fallen trees due to typhoon. </a> </LI>
<Li> <a target = "_ blank" href = "http://news.sina.com.cn/c/2012-07-26/143924850041.shtml"> 13 people died due to disaster recovery in traffic and electric power communication recovery in yesanpo Scenic Area, Hebei </a> </LI>
<Li> <a target = "_ blank" href = "http://kuaixun.stcn.com/content/2012-07/26/content_6390597.htm"> no epidemic has been detected in Fangshan comprehensive disinfection in Beijing. </a> </LI>
<Li> <a target = "_ blank" href = "http://news.022china.com/2012/07-26/722274_0.html"> Beijing Safety Supervision Bureau launches post-disaster check for large concerts in case of heavy rain or stop </a> </LI>
<Li> <a target = "_ blank" href = "http://society.people.com.cn/n/2012/0726/c86800-18604071.html"> Beijing-bao railway resumed to open to train due to heavy rainfall </a> </LI>
</Ul>
</Div>
</Body>
Summary:
Pay attention to the highlighted color part of the CSS code. The column partition is determined by the width of the DIV and Li. When the DIV width is Li width minus n times, it is divided into n columns. For example: aboveRelationnewslistWidth: 660px;The Li width isWidth: 320px;The width multiple is more than twice, so it is divided into two columns. IfRelationnewslistIf the width is set to 900px and the Li width is set to 288px, it is divided into three columns.
The following table lists the display results: