首页 > web前端 > css教程 > 正文

css多行多列的新闻模式_经验交流

PHP中文网
发布: 2016-05-16 12:05:51
原创
1504人浏览过

css多行多列的新闻模式_经验交流

看图:
1060.png

这种效果,甚至是三列四列的新闻模块,以前我都用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多行多列的新闻模式_经验交流的内容,更多相关内容请关注PHP中文网(www.php.cn)!


最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
相关标签:
css
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号