Powered by md-Blog  文 - 篇  访客 -

ES6写一个进行词组单个字放大旋转效果


更新:2020-02-19 20:33:15  /  创建:2020-02-19 20:32:26  /  分类:写一个Demo  / 
不要删除

1、先看效果

img

2、demo.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Demo</title>

    <style>
        body{
            background: #8de2f5;
        }
        .cool {
            margin-top: 200px;
            text-align: center;
            font-size: 80px;
            text-indent: 7px;
            font-weight: bold;
            color: #FFF;
            text-shadow: 3px 3px 10px gray;
        }
        .cool span{
            display: inline-block;
            transition: transform 0.25s;
        }
        .cool span:hover{
            cursor: pointer;
            transform: translateY(-20px) rotate(10deg) scale(2);
        }
    </style>
</head>
<body>
    <div class="cool">Hello World!</div>
</body>
</html>

<script>
'use strict'

const classCool = document.querySelector('.cool');
// console.log(addEffect(classCool.textContent));

classCool.innerHTML = addEffect(classCool.textContent);

function addEffect(word){
    return [...word].map(letter => `<span>${letter}</span>`).join('');
}
</script>
不要删除

小站不易,感谢支持!