RSS
热门关键字:  虚拟主机技术  vps团购  discuz架构  虚拟主机团购  curl
当前位置 :| 团购首页>网站编程>CSS+DIV>

CSS打造渐变统计柱形图

来源: 作者: 时间:2008-11-15 Tag: 点击:

 以前写柱形图时,用的是宽1px的图片底,给width赋一个百分比出可以实现.昨天晚上写一个小统计时想用CSS写一个渐变的!

1.用作图工具作一个渐变的长度.看起来能好看一点(宽:187px;高15px)

2.本来设想是当12%时,图片从左到12%的位置显示,余下的88%不显示,但不占地(看起来和1px的图片底没什么区别).下午时去网罗了一班.发现不占地是不太可能的.

3.要隐藏图片余下的百分比,先想到了评分.亮和暗用了一张图片,各占图片总高度的一半.我写下了:

<div style="background:url(...) 12% left;width:187px;height:15px;"></div>

依次从10%-100%,见不到效果,换<span></span>这个是可以不过在盒子内必须要有内容.

4.昨天晚上没写出来.下午google了也没有找到类4渐变的.不过从其中一个示例中得到了灵感.

URL:http://apples-to-oranges.com/blog/post/css-for-bar-graphs/?id=55

中的:Complex CSS Bar Graph

马上得到了这个:

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
dl{margin:0;padding:0;width:187px;}                  
dd{position:relative;display:block;float:left;width:187px;height:15px; margin:0;border:1px solid #eee;}
* html dd{ float: none; } 
dd div{position:relative;background:url("../image/default/Percent.gif");height:15px;width:100%;text-align:right;}

</style>
</head>

<body>
<dl>   
    <dd>
        <div style="width:5%;"></div>
    </dd>
</dl>
<dl>    
    <dd>
        <div style="width:15%;"></div>
    </dd>
</dl>
<dl>   
    <dd>
        <div style="width:25%;"><strong>55%</strong></div>
    </dd>
</dl>
<dl>
    <dd>
        <div style="width:35%;"><strong>55%</strong></div>
    </dd>
</dl>
<dl>
    <dd>
        <div style="width:45%;"><strong>55%</strong></div>
    </dd>
</dl>
<dl>
    <dd>
        <div style="width:55%;"><strong>55%</strong></div>
    </dd>           
</dl>
<dl>
    <dd>
        <div style="width:65%;"><strong>65%</strong></div>
    </dd>           
</dl>
<dl>
    <dd>
        <div style="width:75%;"><strong>75%</strong></div>
    </dd>           
</dl>
<dl>
    <dd>
        <div style="width:85%;"><strong>85%</strong></div>
    </dd>           
</dl>
<dl>
    <dd>
        <div style="width:95%;"><strong>95%</strong></div>
    </dd>           
</dl>
<dl>
    <dd>
        <div style="width:100%;"><strong>100%</strong></div>
    </dd>           
</dl>

</body>
</html>
有同需求的兄弟可以参考一下

 


 


    由于各种原因,我们无法获知[CSS打造渐变统计柱形图]原创作者,如侵犯了您的版权,请您及时联系我们!
最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册