html动态泡泡,动态气泡菜单.html



HTML5+CSS3气泡式图标菜单特效 - 站长素材

*, *:before, *:after {

box-sizing: border-box;

margin: 0;

padding: 0;

}

:root {

font-size: calc(16px + (20 - 16) * (100vw - 320px)/(980 - 320));

--rotateTimes: 0;

}

body {

background-color: #002;

background-image: radial-gradient(circle at center, #045, #002);

color: #fff;

font: 1em "Open Sans", sans-serif;

height: 100vh;

line-height: 1.5;

}

nav, ul, li {

transform-style: preserve-3d;

}

nav, li {

position: absolute;

top: 50%;

left: 50%;

}

nav, li a {

border-radius: 50%;

}

nav {

width: 18em;

height: 18em;

transform: translate(-50%, -50%) rotateX(75deg);

}

ul, li a {

width: 100%;

height: 100%;

}

ul {

list-style: none;

}

li {

animation: idle 4s ease-in-out infinite;

text-align: center;

width: 5em;

height: 5em;

transform: translate(-50%, -50%);

}

li a {

box-shadow: 0 0 0 0.1em #0cf inset, 0 0 1em #0cf inset;

color: currentColor;

display: inline-block;

text-decoration: none;

transition: transform 0.4s linear, box-shadow 0.15s linear, margin 0.1s linear, width 0.1s linear, height 0.1s linear;

}

li a span {

transition: color 0.15s linear;

}

li a:before {

background-color: #fff;

border-radius: 50%;

content: "";

display: block;

opacity: 0.5;

position: absolute;

top: 0.75em;

left: 0.75em;

width: 1em;

height: 0.5em;

transform: rotate(-45deg);

}

li a:focus, li a.current {

box-shadow: 0 0 0 0.1em #ff0 inset, 0 0 1em #ff0 inset;

outline: 0;

}

li a:focus span, li a.current span {

color: #ff0;

}

li a:hover {

margin: -5% 0 0 -5%;

width: 110%;

height: 110%;

}

li a:hover svg {

width: 3em;

height: 3em;

}

@media (prefers-reduced-motion) {

li {

animation: none;

}

}

svg {

display: block;

margin: 1.25em auto 1.5em auto;

transition: width 0.1s linear, height 0.1s linear;

width: 2.5em;

height: 2.5em;

}

/* Position bubbles */

li:nth-of-type(1) {

animation-delay: 0s;

}

li:nth-of-type(1) a {

transform: rotate(calc(0deg + var(--rotateTimes) * 51.4285714286deg)) translateY(9em) rotate(calc(0deg - var(--rotateTimes) * 51.4285714286deg)) rotateX(-75deg);

}

li:nth-of-type(2) {

animation-delay: -0.5s;

}

li:nth-of-type(2) a {

transform: rotate(calc(-51.4285714286deg + var(--rotateTimes) * 51.4285714286deg)) translateY(9em) rotate(calc(51.4285714286deg - var(--rotateTimes) * 51.4285714286deg)) rotateX(-75deg);

}

li:nth-of-type(3) {

animation-delay: -1s;

}

li:nth-of-type(3) a {

transform: rotate(calc(-102.8571428571deg + var(--rotateTimes) * 51.4285714286deg)) translateY(9em) rotate(calc(102.8571428571deg - var(--rotateTimes) * 51.4285714286deg)) rotateX(-75deg);

}

li:nth-of-type(4) {

animation-delay: -1.5s;

}

li:nth-of-type(4) a {

transform: rotate(calc(-154.2857142857deg + var(--rotateTimes) * 51.4285714286deg)) translateY(9em) rotate(calc(154.2857142857deg - var(--rotateTimes) * 51.4285714286deg)) rotateX(-75deg);

}

li:nth-of-type(5) {

animation-delay: -2s;

}

li:nth-of-type(5) a {

transform: rotate(calc(-205.7142857143deg + var(--rotateTimes) * 51.4285714286deg)) translateY(9em) rotate(calc(205.7142857143deg - var(--rotateTimes) * 51.4285714286deg)) rotateX(-75deg);

}

/* Animations */

.rise {

animation: rise 1s ease-out;

}

.rise a {

animation: fadeOut 1s ease-out;

}

.rise a.pop {

animation: pop 1s linear;

}

.rise a.pop svg, .rise a.pop span {

visibility: hidden;

}

@keyframes rise {

from {

transform: translateZ(0);

}

15% {

transform: translateZ(-1em);

}

to {

transform: translateZ(35em);

}

}

@keyframes fadeOut {

from, 15% {

opacity: 1;

}

50%, to {

opacity: 0;

}

}

@keyframes pop {

from {

margin: -5% 0 0 -5%;

width: 110%;

height: 110%;

opacity: 1;

}

10%, to {

margin: -20% 0 0 -20%;

width: 140%;

height: 140%;

opacity: 0;

}

}

@keyframes idle {

from, to {

transform: translate(-50%, -48%);

}

25% {

transform: translate(-52%, -50%);

}

50% {

transform: translate(-50%, -52%);

}

75% {

transform: translate(-48%, -50%);

}

}

  • Phone

  • Music

  • Map

  • Wi-Fi

  • Settings

document.addEventListener("DOMContentLoaded", function(){

let rise = function(trigEl) {

trigEl.blur();

let ul = document.querySelector("ul");

ul.classList.add("rise");

trigEl.classList.add("pop");

setTimeout(function(){

trigEl.focus();

ul.classList.remove("rise");

trigEl.classList.remove("pop");

}, 1000);

};

this.querySelectorAll("li a").forEach(function(el){

let rt = document.querySelector(":root"),

di = +el.getAttribute("data-item");

el.addEventListener("blur",function(){

//var getRt = +window.getComputedStyle(el).getPropertyValue('--rotateTimes');

//console.log(getRt);

//this.classList.add("current");

});

el.addEventListener("focus",function(){

rt.style.setProperty("--rotateTimes",di);

//this.classList.remove("current");

});

el.addEventListener("dblclick",function(){

rise(this);

});

el.addEventListener("keyup",function(e){

if (e.keyCode === 13) {

rise(this);

}

});

});

});

适用浏览器:360、FireFox、Chrome、Opera、傲游、搜狗、世界之窗. 不支持Safari、IE8及以下浏览器。

来源:站长素材

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值