前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >bootstrap 进度条模拟温度计 原

bootstrap 进度条模拟温度计 原

作者头像
tianyawhl
发布2019-04-04 16:39:50
1.1K0
发布2019-04-04 16:39:50
举报
文章被收录于专栏:前端之攻略前端之攻略

最近需要做一个类似温度计的图表,网上找了好久,也没有找到合适的,现根据bootstrap的进度条来模拟温度计,主要实现根据不同区间的数据来显示不同的颜色,并自适应屏幕大小,在网上找到一个背景图,进度条

放在上面

上面为显示的效果

html 代码

 <div class="col-lg-4">            <h3 class="jiankong-subtitle">温度</h3>            <div class="wendudiv" style="">            <div class="wendu-progress" style="">            <div class="progress-title" style=""><span class="wendu-num">40</span>℃</div>             <div class="progress" style="" >                 <div class="progress-bar" role="progressbar"                      aria-valuenow="60" aria-valuemin="0" aria-valuemax="100"                      style="width: 30%;">                 </div>             </div>             </div>             </div>           </div>

css 样式 .zzsc-content{height:350px;background:#fafafa;text-align:center;padding-top:20px;} .wendudiv{height:350px;width:100%;background:#fafafa;display:table;} .wendu-progress{padding-top:19px;height:76px;background:url(../../dist/img/temp.png) center center no-repeat;display:table-cell;vertical-align:middle;text-align:center;} .progress-title{float:left;margin-left:21.27%;margin-right:15px;} .progress{margin-left:31.9%;margin-right:6.76%;background:#fff;height:23px;} @media(max-width:1750px){ .wendu-progress{background:url(../../dist/img/temp.png) no-repeat center center /90%;}     } 

代码语言:javascript
复制
<script>
   $(document).ready(function(){
   $('.wendu-num').each(function(i,n){
   if($(this).text()<30) {
			   $(this).parent().siblings().children(".progress-bar").addClass("progress-bar-info");
	} else if(30<=$(this).text() && $(this).text()<=50){
			   $(this).parent().siblings().children(".progress-bar").addClass("progress-bar-success");
	} else {
			   $(this).parent().siblings().children(".progress-bar").addClass("progress-bar-danger");
	}
   });
   window.onresize=function(){
       $(".wendudiv").height($(".wendudiv").width()*0.64);
   };
});
 </script>

(adsbygoogle = window.adsbygoogle || []).push({});

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016/09/13 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档