快捷导航
蚂蚁部落 网站首页 实例代码 CSS实例 查看内容

opacity应用代码实例

2017-5-4 17:20| 发布者: admin| 查看: 376| 评论: 0|来自: 蚂蚁部落

分享一段代码实例,它利用opacity实现了渐变的色块效果。

代码实例如下:

[HTML] 纯文本查看 复制代码运行代码
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>蚂蚁部落</title>
<style>
.row{overflow: hidden;}
.row div{
  width: 80px;
  height: 80px;
  line-height: 80px;
  text-align: center;
  float: left;
}
.row:nth-of-type(1) div{
  background-color: #000;
  color: #fff;
}
.row:nth-of-type(2) div{
  background-color: red;
}
.row:nth-of-type(3) div{
  background-color: green;
}
.row:nth-of-type(4) div{
  background-color: blue;
}
.row div:nth-child(1){
  background-color: #000;
  color: #fff;
}
.row div:nth-child(2){
  opacity: 1;
}
.row div:nth-child(3){
  opacity: 0.8;
}
.row div:nth-child(4){
  opacity: 0.6;
}
.row div:nth-child(5){
  opacity: 0.4;
}
.row div:nth-child(6){
  opacity: 0.2;
}
.row:nth-of-type(1) div{
  opacity: 1;
}
</style>
</head>
<body>
  <div class="demo">
    <div class="row">
      <div></div>
      <div>1</div>
      <div>0.8</div>
      <div>0.6</div>
      <div>0.4</div>
      <div>0.2</div>
    </div>
    <div class="row">
      <div>red</div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
    </div>
    <div class="row">
      <div>green</div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
    </div>		
    <div class="row">
      <div>blue</div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
    </div>
  </div>
</body>
</html>

鲜花

握手

雷人

路过

鸡蛋

最新评论

关于我们|手机版|小黑屋| ( 鲁ICP备10022556号-3 )

GMT+8, 2017-8-19 05:59 , Processed in 0.060608 second(s), 21 queries .

Powered by Discuz! X3.2 Licensed

Copyright © 2012-2017 Design: 蚂蚁部落

返回顶部