大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
H5edu教育html5开发为您解答:
创新互联公司专注于企业网络营销推广、网站重做改版、新和网站定制设计、自适应品牌网站建设、H5开发、商城建设、集团公司官网建设、成都外贸网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为新和等各大城市提供网站开发制作服务。
jquery渐变示例
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312" /
titleCycle/title
script type="text/javascript" src="jquery.js"/script
style type="text/css"
table.outTable{
width: 500px;
border-top: #037DC7 1px solid;
border-collapse: collapse;
}
.outTable td{
height: 15px;
border: #037DC7 1px solid;
border-collapse: collapse;
}
table.inTable{
border: #037DC7 0px solid;
}
.inTable td.leftSideTd{
width: 15px;
height: 100px;
line-height:100px;
border-collapse: collapse;
}
/style
script type="text/javascript"
var first = true;
function decrescendo(o) {
$("#td"+o).css("background-color", "#C2F7A6");
$("#td"+o).css("opacity", "1.0");
$("#td"+o).animate({opacity: 0.4}, {duration: 500});
}
function crescendo(o) {
$("#td"+o).css("background-color", "#C2F7A6");
$("#td"+o).css("opacity", "0");
$("#td"+o).animate({opacity: 1}, {duration: 500});
}
function cycle(o){
var preO = o - 1;
if(o == 1) {
preO = 14;
}
//$("#td"+preO).css("background-color", "#FFFFFF");
if(!first) {
decrescendo(preO)
}
first = false;
var nextO = o + 1;
if(o == 14) {
nextO = 1;
}
//$("#td"+o).css("background-color", "#C2F7A6");
crescendo(o)
setTimeout("cycle("+nextO+")", 300);
}
/script
/head
body
input type="button" value="begin" onclick="cycle(1);" /
br /br /br /
div style="margin: 0 auto; align:center;"
table class="outTable" align="center"
tr
td id="td1"/td
td id="td2"/td
td id="td3"/td
td id="td4"/td
/tr
tr
td colspan="2" style="border: 0px;"
table align="left" class="inTable"
tr
td id="td14" class="leftSideTd" style="border-top: 0;"/td
/tr
tr
td id="td13" class="leftSideTd"/td
/tr
tr
td id="td12" class="leftSideTd" style="border-bottom: 0;"/td
/tr
/table
/td
td colspan="2" style="border: 0px;"
table align="right" class="inTable"
tr
td id="td5" class="leftSideTd" style="border-top: 0;"/td
/tr
tr
td id="td6" class="leftSideTd"/td
/tr
tr
td id="td7" class="leftSideTd" style="border-bottom: 0;"/td
/tr
/table
/td
/tr
tr
td id="td11"/td
td id="td10"/td
td id="td9"/td
td id="td8"/td
/tr
/table
/div
/body
/html
需要先加载jquery库
$(function() {
// refreshGradient("#main_operation","#3073e5","#2d9ae6",3);//div背景颜色渐变
});
/*********************************
* 设置标签背景渐变
* @param divId 标签 、 id 、className
* @param color1 渐变开始颜色
* @param color2 渐变结束颜色
* @param type 渐变类型 1=左到右,2=上到下,3=左上到右下,4=左上到右上
*/
function refreshGradient(divId,color1,color2,type) {
var col1 = "#ffffff";
var col2 = "#3074e5";
var div = "body";
if(divId != null){
div = divId;
}
if(color1 != null){
col1 = color1;
}
if(color2 != null){
col2 = color2;
}
var showType = "to right bottom";//默认左上角到右下角
switch (type) {
case 1:
showType = "to right";
break;
case 2:
showType = "to top";
break;
case 3:
showType = "to right bottom";
break;
case 4:
showType = "to right top";
break;
default:
break;
}
var gradientBody = "linear-gradient("+showType+", " +col1+ ", " + col2 + ")";
$.each(["", "-o-", "-moz-", "-webkit-", "-ms-"], function() {
$(div).css({ 'background': this + gradientBody });
});
}
用 animate 来效果变化$("#block").animate({
width: "90%",
height: "100%",
fontSize: "10em",
borderWidth: 10
}, 1000 );