zoukankan
html css js c++ java
基于CSS的柱状图实现
今天偶然见看到的,觉得不错,收藏过来一起学习下。
效果:
<!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> <title> 基于CSS的柱状图实现——Dudo博客 </title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <style type="text/css"> body {padding:0;margin:40px;font-size:12px;font-family:Helvetica,Geneva,sans-serif;} h3 {font-weight:normal;display:block;600px;text-align:center;} /*ul*/ ul#q-graph { border:2px solid #0063be; background:#ffc url(http://www.dudo.org/attachments/month_0805/l2008524151456.png) repeat-x scroll 0 0 !important; background:#ffc repeat-x scroll 0 0; height:300px !important; height:304px; 600px; position:relative; list-style:none; margin:1.1em 1em 3.5em; padding:0; } #q-graph li { position:absolute; text-align:center; bottom:0; padding:0 margin:0; } /* ul li */ li.qtr { 150px; height:300px; border-right:1px dotted #41a3e2; z-index:2; } li#q1 {left:0;} li#q2 {left:150px;} li#q3 {left:300px;} li#q4 {left:450px;border-right:none;} /* ul li ul */ #q-graph ul {list-style:none;} /* ul li ul li */ li.bar { 34px; color:#fff; } li.north { left:36px; background:#ddd url('http://www.dudo.org/attachments/month_0804/c2008428195153.gif') no-repeat 0 0; } li.south { left:80px; background:#ddd url('http://www.dudo.org/attachments/month_0804/c2008428195153.gif') no-repeat -34px 0; } /* ul li divs */ li#ticks { left:0; height:300px; 100%; z-index:1; } div.ticks { position:relative; height:60px; border-top:1px dotted #41a3e2; } div.ticks:first-child {border-top:none;} /*only4 Firefx IE 7+*/ div.ticks p { position:absolute; left:101%; top:-2px; color:#f00; font-weight:bold; } </style> </head> <body> <ul id="q-graph"> <li id="q1" class="qtr">Q1 <ul> <li class="north bar">20</li> <li class="south bar">10</li> </ul></li> <li id="q2" class="qtr">Q2 <ul> <li class="north bar">30</li> <li class="south bar">11</li> </ul></li> <li id="q3" class="qtr">Q3 <ul> <li class="north bar">40</li> <li class="south bar">29</li> </ul></li> <li id="q4" class="qtr">Q4 <ul> <li class="north bar"></li> <li class="south bar">0</li> </ul></li> <li id="ticks"> <div class="ticks"><p>50</p></div> <div class="ticks"><p>40</p></div> <div class="ticks"><p>30</p></div> <div class="ticks"><p>20</p></div> <div class="ticks"><p>10</p></div></li> </ul> <script> function qt(tid,qid){ var Hs=document.getElementById(tid).offsetHeight-5 var oObj=document.getElementById(qid).getElementsByTagName("li"),k=oObj.length; for (var oi=0;oi<k-1;oi++){ if(oObj[oi].id!=''){ var obj=oObj[oi].getElementsByTagName("li"),j=obj.length for (var i=0;i<j;i++){ if (obj[i].innerHTML!="" && parseInt(obj[i].innerHTML)>=0) {obj[i].style.height=Hs*parseInt(obj[i].innerHTML)/50+oi+1+"px"} else {obj[i].style.display="none"} }} } } onload=function(){qt("ticks","q-graph")} </script> </body> </html>
提示:可以先在文本框内,根据需要修改代码后再运行
查看全文
相关阅读:
struts2标签处理下拉列表
JS中parseInt使用问题解析
使用jquery异步无刷新删除
html中table标签的td标签居中左(右)对齐
struts2拦截器来防止sql注入
在S2SH中调用返回参数的存储过程
使用jquery的getJSON从服务器端获得数据
【vue】vuecli中 对于public文件夹的处理
oracle10新建表时大小定问题
会议记录
原文地址:https://www.cnblogs.com/joe235/p/1232433.html
最新文章
如何查看电脑端口号
转:未能找到元数据文件App_Web_pstcl2bp.dll的解决办法
转:GridView 模板列中的数据绑定
SQL之建库、建表、建约束、关系、部分Tsql语句
转:怎么用VS2005打开VS2008的项目
转:js控制asp.net服务器端控件textbox设置为多行时输入字符长度
转:C# 文件操作 全收录 追加、拷贝、删除、移动文件、创建目录、递归删除文件夹及文件
转:GridView 72般绝技
转:点击按钮添加行
代码创建IIS站点
热门文章
vue中template只能有一个root
vue报错Module build failed: TypeError: this.getOptions is not a function site:blog.csdn.net
创建一个脚手架过程
CLS是什么?cls和self有什么区别?
SyntaxError: NonASCII character '\xe6' in file解决方法
java中用poi处理Excel表格之写入(2003和2007通用方法)
一款比较好用的jquery日历控件lhgcalendar
java中用poi处理Excel表格之读取(2003和2007通用方法)
Eclipse中配置jad反编译工具
struts2中iterator标签处理hql返回的不定格式数据
Copyright © 2011-2022 走看看