css实现DIV扩展伸缩效果

时间:2016-07-30
css功能非常强大,向以前的DIV扩展伸缩效果都需要使用到JS,如今可以用纯CSS就能实现,本文章想大家介绍纯css实现的DIV扩展伸缩效果,需要的朋友可以参考一下。

css实现DIV扩展伸缩效果,源代码如下:

<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.expandable .hidden {
  display: none;
}

.expandable:active .hidden, .expandable .hidden:hover {
  display: block;
}

.min {
  width: 50px;
  height: 50px;
  background: green;
  cursor: -moz-zoom-in;
  cursor: -webkit-zoom-in;
}

.full {
  width: 200px;
  height: 200px;
  background: yellow;
  position: relative;
  top: -50px;
}
</style>
</head>
<body>
  <div class="expandable">
    <div class="min"></div>
    <div class="hidden full"></div>
  </div>
</body>
</html>

在线运行