css多行多列的新聞模式_經驗交流

來源:互聯網
上載者:User
css多行多列的新聞模式_經驗交流

看圖:

這種效果,甚至是三列四列的新聞模組,以前我都用table,以為比css方便,直到後來發先了a的浮動之後,原來用ul更方面,更容易控制,先來看看代碼吧:

引用:

.news{} .news li{ list-style:none; clear:both} .news li a#n1{ text-decoration:none; float:left; line-height:22px;} .news li a#n2{ text-decoration:none; float:right; color:#999} .news li a#n3{ float:right; padding-right:20px;color:#999} .news li a#n1:hover{ text-decoration:underline;} .news li a#n3:hover,.news li a#n3:hover{ text-decoration:none;}

a#n1為新聞標題,左浮動,n2和n3為點擊次數和發布日期,右浮動,距離20px;
注意,li上一定要清除所有浮動.
測試支援ie6,ie7,ff,opera.

樣本,三列:

<!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" content="text/html; charset=gb2312" /> <title>css多行多列的新聞模式</title> <style type="text/css"> <!-- *{margin: 0px; padding:0px;} body { font-family:"宋體"; font-size:12px; color:#000; padding:100px;} .news{} .news li{ list-style:none; clear:both} .news li a#n1{ text-decoration:none; float:left; line-height:22px;} .news li a#n2{ text-decoration:none; float:right; color:#999} .news li a#n3{ float:right; padding-right:20px;color:#999} .news li a#n1:hover{ text-decoration:underline;} .news li a#n3:hover,.news li a#n3:hover{ text-decoration:none;} /**/ --> </style></head> <body> 這是三列 <ul class="news"> <li>左列,新聞標題項點 擊發布日期</li> <li>>> 熱烈祝賀weilaixu.cn隆重上線88882008-08-08</li> <li>>> 熱烈祝賀weilaixu.cn隆重上線88882008-08-08</li> <li>>> 熱烈祝賀weilaixu.cn隆重上線88882008-08-08</li> <li>>> 熱烈祝賀weilaixu.cn隆重上線88882008-08-08</li> </ul> </body> </html>

樣本,二列:

<!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" content="text/html; charset=gb2312" /> <title>css多行多列的新聞模式</title> <style type="text/css"> <!-- *{margin: 0px; padding:0px;} body { font-family:"宋體"; font-size:12px; color:#000; padding:100px;} .news{} .news li{ list-style:none; clear:both} .news li a#n1{ text-decoration:none; float:left; line-height:22px;} .news li a#n2{ text-decoration:none; float:right; color:#999} .news li a#n3{ float:right; padding-right:20px;color:#999} .news li a#n1:hover{ text-decoration:underline;} .news li a#n3:hover,.news li a#n3:hover{ text-decoration:none;} --> </style></head> <body> 這是二列 <ul class="news"> <li>左列,新聞標題項點擊次數</li> <li>>> 熱烈祝賀weilaixu.cn隆重上線2008-08-08</li> <li>>> 熱烈祝賀weilaixu.cn隆重上線2008-08-08</li> <li>>> 熱烈祝賀weilaixu.cn隆重上線2008-08-08</li> <li>>> 熱烈祝賀weilaixu.cn隆重上線2008-08-08</li> </ul> </body> </html>

樣本,虛線:

<!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" content="text/html; charset=gb2312" /> <title>css多行多列的新聞模式</title> <style type="text/css"> <!-- *{margin: 0px; padding:0px;} body { font-family:"宋體"; font-size:12px; color:#000; padding:100px;} .news2{} .news2 li{ list-style:none;clear:both;margin-top:10px;border-bottom:1px dashed #ccc;height:16px; display:block} .news2 li a#n1{ text-decoration:none;float:left;} .news2 li a#n2{ text-decoration:none; float:right; color:#999;display:block} .news2 li a#n3{ float:right; padding-right:20px;color:#999; display:block} .news2 li a#n1:hover{ text-decoration:underline;} .news2 li a#n3:hover,.news li a#n3:hover{ text-decoration:none;}  /**/ --> </style></head> <body> 加條虛線 <ul class="news2"> <li>>> 熱烈祝賀weilaixu.cn隆重上線2008-08-08</li> <li>>> 熱烈祝賀weilaixu.cn隆重上線2008-08-08</li> <li>>> 熱烈祝賀weilaixu.cn隆重上線2008-08-08</li> <li>>> 熱烈祝賀weilaixu.cn隆重上線2008-08-08</li> </ul> </body> </html>


樣本,不同背景色:

<!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" content="text/html; charset=gb2312" /> <title>css多行多列的新聞模式</title> <style type="text/css"> <!-- *{margin: 0px; padding:0px;} body { font-family:"宋體"; font-size:12px; color:#000; padding:100px;} .news{} .news3{ background:#ccc;} .news3 li{ list-style:none; clear:both; height:20px; padding-top:8px;} .news3 li#x1{ list-style:none; clear:both; height:20px; background-color:#F2F2F2} .news3 li a#n1{ text-decoration:none; float:left;} .news3 li a#n2{ text-decoration:none; float:right; color:#999} .news3 li a#n3{ float:right; padding-right:20px;color:#999} .news3 li a#n1:hover{ text-decoration:underline;} .news3 li a#n3:hover,.news li a#n3:hover{ text-decoration:none;} --> </style></head> <body> 不同背景色 <ul class="news3"> <li>>> 熱烈祝賀weilaixu.cn隆重上線2008-08-08</li> <li id="x1">>> 熱烈祝賀weilaixu.cn隆重上線2008-08-08</li> <li>>> 熱烈祝賀weilaixu.cn隆重上線2008-08-08</li> </ul> </body> </html>


樣本,邊框:

<!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" content="text/html; charset=gb2312" /> <title>css多行多列的新聞模式</title> <style type="text/css"> <!-- *{margin: 0px; padding:0px;} body { font-family:"宋體"; font-size:12px; color:#000; padding:100px;} .news4{} .news4 li{ list-style:none; clear:both;margin-top:10px; padding:10px; border:1px solid #ccc;  display:block} .news4 li a#n1{ text-decoration:none;float:left;} .news4 li a#n2{ text-decoration:none; float:right; color:#999;display:block} .news4 li a#n3{ float:right; padding-right:20px;color:#999; display:block} .news4 li a#n1:hover{ text-decoration:underline;} .news4 li a#n3:hover,.news li a#n3:hover{ text-decoration:none;} /**/ --> </style></head> <body> 邊框 <ul class="news4"> <li>>> 熱烈祝賀weilaixu.cn隆重上線2008-08-08</li> <li>>> 熱烈祝賀weilaixu.cn隆重上線2008-08-08</li> <li>>> 熱烈祝賀weilaixu.cn隆重上線2008-08-08</li> <li>>> 熱烈祝賀weilaixu.cn隆重上線2008-08-08</li> </ul> </body> </html>

以上就是css多行多列的新聞模式_經驗交流的內容,更多相關內容請關注topic.alibabacloud.com(www.php.cn)!

  • 相關文章

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.