纯CSS柱状图,无动画

<html>
<head>

  <meta charset="UTF-8">

  <title</title>

    <link rel="stylesheet" href="style.css" media="screen" type="text/css">

</head>

<body>

<section class="data">

  <div class="bar-wrap">
    <label>Data 1</label>
    <div class="bar green" data-percentage="21" style="width: 21%;"></div>
  </div>
  <div class="bar-wrap">
    <label>Data 2</label>
    <div class="bar red" data-percentage="78.95" style="width: 78.95%;"></div>
  </div>
  <div class="bar-wrap">
    <label>Data 3</label>
    <div class="bar blue" data-percentage="94.7" style="width: 94.7%;"></div>
  </div>
  
</section>

</body></html>


style.css代码:

*, *:before, *:after {
  box-sizing: border-box;
}

body {
  font-family: 'Source Sans Pro', sans-serif;
  font-weight: 300;
  font-size: 14px;
  padding: 30px;
  background: #eaeaea;
}


section.data {
  position: relative;
  overflow: hidden;
}

div.bar-wrap {
  width: 100%;
  display: block;
  margin: 0 0 20px 0;
  overflow: hidden;
}
div.bar-wrap label {
  font-size: 0.8em;
  color: #8a8a8a;
  text-transform: uppercase;
  margin: 0 0 2px 0;
  display: block;
}
div.bar-wrap div.bar {
  height: 40px;
  width: 0;
  position: relative;
}
div.bar-wrap div.bar:after {
  content: attr(data-percentage) "%";
  display: block;
  position: absolute;
  top: 0;
  right: 0;
  height: 40px;
  padding: 10px;
}
div.bar-wrap div.bar.blue {
  background-color: #61a7c4;
  border-bottom: 3px solid #4290b0;
}
div.bar-wrap div.bar.blue:after {
  color: #FFF;
}
div.bar-wrap div.bar.green {
  background-color: #61c471;
  border-bottom: 3px solid #42b054;
}
div.bar-wrap div.bar.green:after {
  color: #FFF;
}
div.bar-wrap div.bar.red {
  background-color: #c46161;
  border-bottom: 3px solid #b04242;
}
div.bar-wrap div.bar.red:after {
  color: #FFF;
}
div.bar-wrap div.bar.purple {
  background-color: #a461c4;
  border-bottom: 3px solid #8d42b0;
}
div.bar-wrap div.bar.purple:after {
  color: #FFF;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值