js+css实现爱心贴纸表白动画交互效果代码

代码语言:html

所属分类:表白

代码描述:js+css实现爱心贴纸表白动画交互效果代码

代码标签: js css 爱心 贴纸 表白 动画 交互

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>暖心提示</title>
        <!-- 图标 -->
        <link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>❤️</text></svg>">
        <link rel="apple-touch-icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>❤️</text></svg>">
        <link rel="shortcut icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>❤️</text></svg>">
        <!-- 样式 -->
    
      <style>
      * {
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

body {
    background-color: #f9f3f3;
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    user-select: none
}

.container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0
}

.heart-point {
    position: absolute;
    width: 100px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 8px;
    text-align: center;
    font-size: 12px;
    color: #333;
    font-weight: bold;
    opacity: 0;
    animation: fadeIn .5s forwards;
    cursor: pointer;
    transition: transform .3s ease,box-shadow .3s ease,background-color .3s ease,z-index .3s ease;
    z-index: 1
}

.heart-point:hover {
    transform: scale(1.15);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
    z-index: 10
}

.heart-point.enlarged {
    transform: scale(2.5)!important;
    transition: transform .4s cubic-bezier(0.175,0.885,0.32,1.275),box-shadow .4s ease,z-index .4s ease;
    transform-origin: center;
    box-shadow: 0 15px 40px rgba(0,0,0,0.4)!important;
    border: 2px solid #fff;
    z-index: 999!important
}

.heart-point.enlarged:hover {
    transform: scale(2.5)!important;
    z-index: 999!important
}

@media(max-width: 768px) {
    .heart-point.enlarged {
        transform:scale(2)!important
    }

    .heart-point.enlarged:hover {
        transform: scale(2)!important
    }
}

@media(max-width: 480px) {
    .heart-point.enlarged {
        transform:scale(1.8)!important
    }

    .heart-point.enlarged:hover {
        transform: scale(1.8)!important
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.8)
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1)
    }
}

.title {
    position: absolute;
    top: 50px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 36px;
    color: #ff1493;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    z-index: 100;
    animation: pulse 2s infinite
}

@keyframes pulse {
    0% {
        transform: scale(1)
    }

    50% {
        transform: scale(1.05)
    }

    100% {
        transform: scale(1)
    }
}

.footer {
    position: absolute;
    bottom: 10px;
    left: 0;
    width: 100%;
    text-align: center;
    color: #363636;
    font-size: 12px;
    z-index: 100
}

@media(max-width: 768px) {
    .heart-point {
        width:80px;
        height: 40px;
        font-size: 10px
    }

    .title {
        font-size: 28px;
        top: 30px
    }
}

@media(max-width: 480px) {
    .heart-point {
        width:70px;
        height: 35px;
        font-size: 9px
    }

    .title {
        font-size: 24px;
        top: 20px
    }

    .footer {
        font-size: 10px;
        bottom: 20px
    }
}

      #fireworks-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000
}

.firework-particle {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    animation: firework-fade 1s ease-out forwards
}

@keyframes firework-fade {
    0% {
        opacity: 1;
        transform: translate(0,0) scale(1)
    }

    .........完整代码请登录后点击上方下载按钮下载查看

网友评论0