用PHP和JS分别实现隔行换色
来源:互联网 发布:美国三维设计软件 编辑:程序博客网 时间:2024/05/02 00:40
1.PHP实现隔行换色
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><?php /*隔行换色,<center>标签可以居中*/echo "<center><ul style='list-style-type:none;font-size:20px;margin-top:100px'>"; for($i=1;$i<=8;$i++) //输出8行 { switch ($i%3) { //根据$i的取值,来給$color赋值 case 0: $color="red"; break; case 1: $color="green"; break; case 2: $color="blue"; break; default: $color="white"; break; } echo "<li style='background-color:".$color.";width:200;padding:20px'>这是第".$i."行</li>"; } echo "</ul></center>";?></body></html>
2.JS实现隔行换色
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>JS实现隔行换色</title><style type="text/css"> *{margin:0px;padding: 0px;}#ul{margin:100px auto;}#ul li{list-style: none;width:300px;height: 50px;border:1px solid red;}</style></head><body><center><ul id="ul"></ul></center><script type="text/javascript">var oUl=document.getElementById("ul"); //获取ul节点var aColor=null;for(var i=0;i<9;i++){switch(i%3){ case 0:aColor="red";break;case 1:aColor="green";break;case 2:aColor="blue";break;default:aColor="white";break;}var aLi=document.createElement("li"); //创建li节点aLi.style.backgroundColor=aColor; //设置li的背景颜色oUl.appendChild(aLi); //添加li节点};</script></body></html>
3.效果图
(1)用JS实现的效果图
(2) 用PHP实现的效果图
1 0
- 用PHP和JS分别实现隔行换色
- js实现隔行换色
- JS实现隔行换色
- 纯js实现隔行换色实例
- js隔行换色
- 隔行换色js
- 放弃class与js实现隔行换色效果
- html中用js实现的表格隔行换色
- jquery 实现隔行换色
- jquery实现隔行换色
- css3实现隔行换色
- AngularJS实现隔行换色
- css和js处理隔行换色的问题
- jQuery实现table隔行换色和鼠标经过变色
- jQuery实现table隔行换色和鼠标经过变色
- jQuery实现table隔行换色和鼠标经过变色
- 用JS完成对表格的隔行换色
- js操作表格目的隔行换色
- dgsdg
- Selenium环境准备
- 06_Java基本数据类型
- VMware虚拟机中,Cent OS下中文乱码的解决方法
- nginx学习2——常用命令操作
- 用PHP和JS分别实现隔行换色
- 关于分布式事务、两阶段提交、一阶段提交、Best Efforts 1PC模式和事务补偿机制的研究
- J2ee关于getattribute和getParaments
- FFmpeg深入分析之零-基础
- android 设置线程优先级 两种方式
- Ural 1203 Scientific Conference
- (十二)关于using namespace std
- 通过RTMP协议将AAC数据发送到流媒体服务器
- 第一篇博客,HelloWorld