下面请跟着图老师小编一起来了解下CSS条状图表形式的实现方法,精心挑选的内容希望大家喜欢,不要忘记点个赞哦!
【 tulaoshi.com - Web开发 】
CSS条状图表是我们在网页设计中常常会遇到的一种形式。条状图表可以将数量,以条状图形的形式直观的表示出来。
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)CSS基本条状图表的实现方法是什么?我们看下面的实例介绍:
以下是引用片段:
div class="graph" 
    strong class="bar" style="width: 24%;"24%/strong 
/div 
这是xhtml代码,定义了一个容器,应用类graph,其中包括了一个xhtml元素strong,并且对这个元素应用类bar。
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)我们看下面的CSS定义:
以下是引用片段:
.graph {  
        position: relative; /* IE is dumb */ 
        width: 200px;  
        border: 1px solid #B1D632;  
        padding: 2px;  
    } 
    .graph .bar {  
        display: block; 
        position: relative; 
        background: #B1D632;  
        text-align: center;  
        color: #333;  
        height: 2em;  
        line-height: 2em;             
    } 
    .graph .bar span { position: absolute; left: 1em; } 
  通过上面的边框,颜色的定义,我们勾勒出了一个条状的图形,我们在xhtml代码中style="width: 24%;",定义了所设置的区域既大小。这样一个基本的条状图表就完成了!
全部代码:
以下是引用片段:
!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" / 
titlehomepage.yesky.com/title 
style type="text/css" 
    .graph {  
        position: relative; /* IE is dumb */ 
        width: 200px;  
        border: 1px solid #B1D632;  
        padding: 2px;  
    } 
    .graph .bar {  
        display: block; 
        position: relative; 
        background: #B1D632;  
        text-align: center;  
        color: #333;  
        height: 2em;  
        line-height: 2em;             
    } 
    .graph .bar span { position: absolute; left: 1em; } 
/style 
/head 
body 
div class="graph" 
    strong class="bar" style="width: 24%;"24%/strong 
/div 
br / 
div class="graph" 
    strong class="bar" style="width: 60%;"60%/strong 
/div 
/body 
/html 
来源:http://www.tulaoshi.com/n/20160219/1623737.html
看过《CSS条状图表形式的实现方法》的人还看了以下文章 更多>>