Home > Web Front-end > CSS Tutorial > CSS multi-row and multi-column news mode_Experience exchange

CSS multi-row and multi-column news mode_Experience exchange

PHP中文网
Release: 2016-05-16 12:05:51
Original
1398 people have browsed it

css multi-row and multi-column news mode_experience exchange

look at the picture:
CSS multi-row and multi-column news mode_Experience exchange

this effect is even three-dimensional for the four-column news module, i used to use table, thinking it was more convenient than css. it was not until i developed the float of a that i found that using ul was more convenient and easier to control. let’s take a look at the code first:

quote:

.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;}
Copy after login

a#n1 is the news title, floating on the left, n2 and n3 are the number of clicks and release date , right float, distance 20px;
note that all floats must be cleared on li.
the test supports ie6, ie7, ff, opera.

example, three columns: p>

<!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>
Copy after login

example, two columns:

<!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>
Copy after login

example, dashed line:

<!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>
Copy after login


example, different background colors:

<!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>
Copy after login


example, border:

<!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>
Copy after login

the above is the css multi-row and multi-column news mode_experience exchange content, please pay attention to the php chinese website (m.sbmmt.com) for more related content!


Related labels:
css
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template