纯CSS3液态胶合效果的环形菜单按钮特效

所属分类:导航-其他导航

 33964  472  查看评论 (5)
分享到微信朋友圈
X
纯CSS3液态胶合效果的环形菜单按钮特效 ie兼容9

使用方法 

HTML结构

在HTML结构中,主菜单按钮使用input[type='checkbox']的复选框和一个<label>元素来制作。子菜单按钮是一组<button>元素。

<div class='wrap'>
  <input type='checkbox' id='checking' style='display:none;' />
  <button class='blob'>★</button>
  <button class='blob'>?</button>
  <button class='blob'>?</button>
  <button class='blob'>?</button>
  <button class='blob'>?</button>
  <button class='blob'>?</button>
  <button class='blob'>?</button>
  <button class='blob'>?</button>
  <label class='blob' for='checking'>
    <span class='bar'></span>      
    <span class='bar'></span>
    <span class='bar'></span>
  </label>
</div>

该环形菜单的液态融合效果使用SVG过滤器来制作。在SVG过滤器中,有3个滤镜:第一个是高斯模糊滤镜,第二个是颜色矩阵滤镜,第三个是混合滤镜。混合滤镜可以将多个输入滤镜混合为一个。

<svg>
  <defs>
    <filter id="filt">
      <feGaussianBlur in="SourceGraphic" result="blur" stdDeviation="10" />
      <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 18 -7" result="filt" />
      <feBlend in2="filt" in="SourceGraphic" result="mix" />
    </filter>
  </defs>
</svg>

在这个效果中,颜色矩阵滤镜的输入是高斯模糊滤镜,然后混合滤镜将颜色矩阵的输出和源图像进行混合,制作液体融合效果。       

CSS样式

在CSS样式中,需要注意的是引用SVG过滤器的方式。在非webkit内核的浏览器中,外连的css样式表中引用SVG过滤器需要写完整的路径,而如果是内联的CSS样式可以直接通过ID来引用。

filter: url("../index.html/#filt");
-webkit-filter: url("#filt");

主菜单按钮的点击时通过checkbox hack来实现的。

.wrap .blob[for="checking"] {
  z-index: 30;
  font-size: 60px;
  text-align: center;
  color: #fff;
  transition: transform 0.5s ease-in-out 0.2s;
  -webkit-transition: -webkit-transform 0.5s ease-in-out 0.2s;
  -moz-transition: transform 0.5s ease-in-out 0.2s;
  -o-transition: transform 0.5s ease-in-out 0.2s;
  -ms-transition: transform 0.5s ease-in-out 0.2s;
}
.wrap .blob:not([for="checking"]) {
  width: 50px;
  height: 50px;
  top: 15px;
  left: 15px;
  font-size: 30px;
  transition: all 0.5s ease-in-out;
  -webkit-transition: all 0.5s ease-in-out;
  -moz-transition: all 0.5s ease-in-out;
  -o-transition: all 0.5s ease-in-out;
  -ms-transition: all 0.5s ease-in-out;
}
.wrap .blob:not([for="checking"]):hover {
  color: #F44336;
  animation: harlem 0.5s linear forwards;
  -webkit-animation: harlem 0.5s linear forwards;
  -moz-animation: harlem 0.5s linear forwards;
  -o-animation: harlem 0.5s linear forwards;
  -ms-animation: harlem 0.5s linear forwards;
}
.wrap > #checking:checked ~ .blob:nth-child(2) {
  margin-left: 85px;
  margin-top: 10px;
  background-color: #fff;
}
.wrap > #checking:checked ~ .blob:nth-child(3) {
  margin-top: 145px;
  margin-left: 65px;
  background-color: #fff;
}
.wrap > #checking:checked ~ .blob:nth-child(4) {
  margin-top: 160px;
  margin-left: 10px;
  background-color: #fff;
}
.wrap > #checking:checked ~ .blob:nth-child(5) {
  margin-top: 85px;
  margin-left: 10px;
  background-color: #fff;
}
.wrap > #checking:checked ~ .blob:nth-child(6) {
  margin-top: 63px;
  margin-left: 63px;
  background-color: #fff;
}
.wrap > #checking:checked ~ .blob:nth-child(7) {
  margin-top: 65px;
  margin-left: 145px;
  background-color: #fff;
}
.wrap > #checking:checked ~ .blob:nth-child(8) {
  margin-top: 112px;
  margin-left: 112px;
  background-color: #fff;
}
.wrap > #checking:checked ~ .blob:nth-child(9) {
  margin-top: 10px;
  margin-left: 160px;
  background-color: #fff;
}
.wrap > #checking:checked ~ .blob[for="checking"] > .bar:nth-child(1) {
  transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
  -moz-transform: rotate(45deg);
  -o-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  margin-top: 37px;
}
.wrap > #checking:checked ~ .blob[for="checking"] > .bar:nth-child(2) {
  transform: rotate(-45deg);
  -webkit-transform: rotate(-45deg);
  -moz-transform: rotate(-45deg);
  -o-transform: rotate(-45deg);
  -ms-transform: rotate(-45deg);
  margin-top: -10px;
}
.wrap > #checking:checked ~ .blob[for="checking"] > .bar:nth-child(3) {
  opacity: 0;
}

harlem帧动画是鼠标滑过子菜单时的CSS动画效果。完整的代码请参考下载文件。

相关插件-其他导航

jquery分类导航

jquery分类导航
  其他导航
 41141  427

jQuery仿微信自定义菜单

jQuery仿微信自定义菜单全屏自适应手机底部弹出菜单
  其他导航
 32992  376

jQuery圆形气泡导航

jQuery圆形气泡导航,ie6下运行也ok。
  其他导航
 40412  485

路径菜单path-menu

巨牛逼的用css3完成的导航!
  其他导航
 40700  405

讨论这个项目(5)回答他人问题或分享插件使用方法奖励jQ币 评论用户自律公约

    V仔就是威仔 0
    2019/12/20 16:36:19
    您好,楼主,我把原本向右下角方向展开的效果改成向左上角方向展开。这卡顿问题解决? 回复
    1007014448 0
    2019/8/23 9:59:29
    效果很绚丽哦,收藏了,谢谢雷锋分享!! 回复
    lev1 0
    2018/4/4 12:02:25
    问题最大的是 在移动位置之后 svg会有卡顿效果 回复
    ZBrettonYe 0
    2018/2/13 10:48:27
    这按钮,想改个位置 还真烦
    回复
    流淌在心上的河流 0
    2018/1/20 14:38:27
    function () {
       var he = 'he';
    }
    回复
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
取消回复