最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

javascript實(shí)現(xiàn)動(dòng)態(tài)顯示顏色塊的報(bào)表效果

 更新時(shí)間:2017年04月10日 10:14:57   作者:攻速鞋  
本文主要介紹了javascript實(shí)現(xiàn)動(dòng)態(tài)顯示顏色塊的報(bào)表效果的相關(guān)知識(shí)。具有很好的參考價(jià)值。下面跟著小編一起來(lái)看下吧

利用html的顏色塊動(dòng)態(tài)展示數(shù)據(jù)

<style type="text/css">
 *{
 padding: 0;
 margin: 0;
 }
 .tubiao,.jihua,.shiji,.riqi{
 width: 100%;
 overflow: hidden;
 margin-top: 10px;
 }
 .left{
 width: 10%;
 float: left;
 text-align: center;
 height: 25px;
 line-height: 25px;
 }
 .right{
 width: 90%;
 float: right;
 height: 25px;
 }
 span {
 width: 5%;
 height: 100%;
 text-align: center;
 display: inline-block;
 }
 </style>
<body>
 <div class="tubiao">
 <div class="jihua">
 <div class="left">計(jì)劃</div>
 <!--計(jì)劃span存放的地方-->
 <div class="right plan"></div>
 </div>
 <div class="shiji">
 <div class="left">實(shí)際</div>
 <!--實(shí)際span存放的地方-->
 <div class="right act"></div>
 </div>
 <div class="riqi" id="day_id">
 <!--日期存放的地方-->
 <div class="right day"></div>
 </div>
 </div>
 <script type="text/javascript">
 var temp1="0-0.5-2-2-2-2-1-1";//計(jì)劃耗時(shí)(塊的單位寬度)
 var temp2="1-1-2-1-2-0-0-0";//實(shí)際耗時(shí)(塊的單位寬度) 
 var temp3="5/19-5/20-5/21-5/22-5/23-5/24-5/25-5/26-5/27-5/28";//綜合日期
 var temp=temp1+"~"+temp2+"~"+temp3; 
 var plan = document.getElementsByClassName("plan")[0];
 var act = document.getElementsByClassName("act")[0];
 var day = document.getElementsByClassName("day")[0];
 var num = 20;//創(chuàng)建多少個(gè)格
 load_first(temp);
 //分割數(shù)據(jù)和添加色塊操作
 function load_first(temp){
 var demo=temp.split("~");
 var d1=demo[0].split("-");//計(jì)劃耗時(shí)(塊的單位寬度)數(shù)組
 var d2=demo[1].split("-");////實(shí)際耗時(shí)(塊的單位寬度)數(shù)組
 var d3=demo[2].split("-");//綜合日期數(shù)組
 for(var i=0;i<d3.length;i++){
 time_span(d3[i]);
 }
 //alert("6:"+d1.length+"---"+"3:"+d2.length);
 //alert("d3.length:"+d3.length);
 for(var i=0;i<d1.length;i++){ 
 add_span(d1[i],d2[i],i);
 }
 document.getElementById("day_id").style.marginLeft="-30px"; 
 } 
 //新增顏色塊,a為計(jì)劃顏色塊寬度,b為實(shí)際顏色塊寬度
 function add_span(a,b,i){
 //創(chuàng)建span塊
 var span1 = document.createElement("span");
 var span2 = document.createElement("span");
 //定義隨機(jī)底色
 var spa = "rgba(" + rnd(0,255)+ "," + rnd(0,255)+ ","+ rnd(0,255)+ ","+ rnd(0.5,1) +")";//每一個(gè)顏色隨機(jī)出來(lái)
 if(i==0){
 span1.style.backgroundColor = "000000";
 //clientWidth是對(duì)象看到的寬度(不含邊線,即border)
 span1.style.width = (plan.clientWidth/num*a) + "px";//計(jì)劃的每一格的寬度
 //插入節(jié)點(diǎn)span1至plan
 plan.appendChild(span1);
 span2.style.backgroundColor = "000000";
 span2.style.width = (plan.clientWidth/num*b) + "px";//實(shí)際的每一格的寬度
 act.appendChild(span2);
 }else{
 //alert("a:"+a+"b:"+b+"i:"+i);
 if(a=="0"){
 span1.style.backgroundColor = "000000"; 
 span1.style.width = (plan.clientWidth/num*a) + "px";//計(jì)劃的每一格的寬度
 //插入節(jié)點(diǎn)span1至plan
 plan.appendChild(span1);
 }else{
 span1.style.backgroundColor = spa;
 //clientWidth是對(duì)象看到的寬度(不含邊線,即border)
 span1.style.width = (plan.clientWidth/num*a) + "px";//計(jì)劃的每一格的寬度
 //插入節(jié)點(diǎn)span1至plan
 plan.appendChild(span1);
 }
 if(b=="0"){
 span2.style.backgroundColor = "000000";
 span2.style.width = (plan.clientWidth/num*b) + "px";//實(shí)際的每一格的寬度
 act.appendChild(span2); 
 }else{
 span2.style.backgroundColor = spa;
 span2.style.width = (plan.clientWidth/num*b) + "px";//實(shí)際的每一格的寬度
 act.appendChild(span2);
 } 
 }
 } 
 //日期的數(shù)據(jù)插入
 function time_span(time){
 //創(chuàng)建span塊
 var span = document.createElement("span"); 
 span.style.width = (plan.clientWidth/num*1) + "px";//每一個(gè)span的寬度 
 span.innerHTML = "" + time;
 day.appendChild(span);
 }
 //隨機(jī)函數(shù)
 function rnd(min,max){
 return Math.round(Math.random()*(max - min)+min); 
 }
 function QueryData() {
 var displayStyle = "1";
 $.ajax({
 type: "post",
 url: "Test.aspx",
 dataType: "text",
 data: { "DispalyStyle": displayStyle },
 error: function (XMLHttpRequest, textStatus, errorThrown) {
 alert(errorThrown + XMLHttpRequest.responseText);
 },
 success: function (json) {
 try {
 load_first(json);
 }
 catch (e) { }
 }
 });
 }
 //QueryData();
 </script>
 </body>

以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,同時(shí)也希望多多支持腳本之家!

相關(guān)文章

  • 純JS實(shí)現(xiàn)圖片驗(yàn)證碼功能并兼容IE6-8(推薦)

    純JS實(shí)現(xiàn)圖片驗(yàn)證碼功能并兼容IE6-8(推薦)

    這篇文章主要介紹了純JS實(shí)現(xiàn)圖片驗(yàn)證碼功能并兼容IE6-8瀏覽器,需要的朋友可以參考下
    2017-04-04
  • JS中prototype關(guān)鍵字的功能介紹及使用示例

    JS中prototype關(guān)鍵字的功能介紹及使用示例

    prototype 關(guān)鍵字可以為JS原有對(duì)象或者自己創(chuàng)建的類中添加方法或者屬性。也可以實(shí)現(xiàn)繼承,下面以實(shí)例的方式為大家詳細(xì)介紹下
    2013-07-07
  • js中hasOwnProperty的屬性及實(shí)例用法詳解

    js中hasOwnProperty的屬性及實(shí)例用法詳解

    在本篇文章里小編給大家整理的是一篇關(guān)于js中hasOwnProperty的屬性及實(shí)例用法詳解內(nèi)容,有需要的朋友們可以跟著學(xué)習(xí)下。
    2021-11-11
  • JavaScript中函數(shù)的防抖與節(jié)流詳解

    JavaScript中函數(shù)的防抖與節(jié)流詳解

    這篇文章主要為大家詳細(xì)介紹了JavaScript中函數(shù)的防抖與節(jié)流,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助
    2022-02-02
  • ie 調(diào)試javascript的工具

    ie 調(diào)試javascript的工具

    其實(shí),沒(méi)那么強(qiáng)大的,不過(guò),聊勝于無(wú)吧,并且還算管用,要是有誰(shuí)再完善它就好了……
    2009-04-04
  • window.print()打印html網(wǎng)頁(yè)的兩種方法實(shí)現(xiàn)

    window.print()打印html網(wǎng)頁(yè)的兩種方法實(shí)現(xiàn)

    本文主要介紹了window.print()打印html網(wǎng)頁(yè)的兩種方法實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-06-06
  • JS實(shí)現(xiàn)圖片預(yù)加載無(wú)需等待

    JS實(shí)現(xiàn)圖片預(yù)加載無(wú)需等待

    網(wǎng)站開發(fā)時(shí)經(jīng)常需要在某個(gè)頁(yè)面需要實(shí)現(xiàn)對(duì)大量圖片的瀏覽;用javascript來(lái)實(shí)現(xiàn)一個(gè)圖片瀏覽器,讓用戶無(wú)需等待過(guò)長(zhǎng)的時(shí)間就能看到其他圖片
    2012-12-12
  • 深入了解JavaScript中的new關(guān)鍵字

    深入了解JavaScript中的new關(guān)鍵字

    手寫new是JS面試題高頻考點(diǎn),實(shí)現(xiàn)代碼也非常簡(jiǎn)單,但在實(shí)現(xiàn)后小編對(duì)其為什么要這樣設(shè)計(jì)有著很深的疑惑,今天就來(lái)講一下為什么要這樣設(shè)計(jì)new的實(shí)現(xiàn)吧
    2023-05-05
  • 原生javascript實(shí)現(xiàn)圖片無(wú)縫滾動(dòng)效果

    原生javascript實(shí)現(xiàn)圖片無(wú)縫滾動(dòng)效果

    這篇文章主要介紹了原生javascript實(shí)現(xiàn)圖片無(wú)縫滾動(dòng)效果的相關(guān)資料,需要的朋友可以參考下
    2016-02-02
  • JS動(dòng)態(tài)顯示倒計(jì)時(shí)效果

    JS動(dòng)態(tài)顯示倒計(jì)時(shí)效果

    這篇文章主要介紹了JS實(shí)現(xiàn)倒計(jì)時(shí)效果動(dòng)態(tài)顯示倒計(jì)時(shí)功能,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-12-12

最新評(píng)論

龙井市| 镇康县| 县级市| 横峰县| 左贡县| 新民市| 伊宁县| 双流县| 辉县市| 上高县| 文化| 石屏县| 汝州市| 辽宁省| 祁东县| 买车| 南溪县| 房山区| 恩平市| 张掖市| 陕西省| 陇南市| 积石山| 新平| 疏勒县| 泽州县| 本溪| 阿鲁科尔沁旗| 花莲县| 盐城市| 武平县| 奉节县| 韩城市| 白河县| 江陵县| 乐清市| 锡林郭勒盟| 什邡市| 若羌县| 晋城| 德江县|