当 h1 的字体大小发生变化时,将 :hover 属性 调整为新的 属性

Adjust :hover property to a new property when the font-size of h1 has changed

我有一个小问题...当我使用@keyframes 更改了文本的外观时,我不知道如何调整 :hover 字母间距 属性...更具体地说:悬停会像这样改变我的 h1 外观:字体大小、位置、字母间距等。字母间距默认为 0rem,但是当我将鼠标悬停在文本上时,它会变为 1rem。效果很好,但我添加了一个动画,它改变了位置,h1 的字体大小,from font-size: 12.5rem;字体大小:5rem;问题是当我悬停时我不知道如何更改字母间距。 font-size为12.5rem时;它看起来不错,但是当动画完成时,字体大小为 5rem,当我将鼠标悬停在它上面时,它看起来很糟糕,字母间距为 1rem。我需要一些帮助...如您所见,它会更改其位置和字体大小,悬停保持为 1 rem,当它具有 font-size12.5rem 时,我想将悬停字母间距从 1rem 更改为0.2rem idk 当我将鼠标悬停在它上面时它的字体大小为 5rem ...我希望你明白我在说什么,顺便说一句,如果我犯了任何语法错误,请随时纠正我,我不是本地人演讲者,有时我在英语方面遇到困难,因此我需要知道我什么时候错了。顺便说一句。

body{
    margin: 0;
    padding: 0;
    font-family: "Montserrat", sans-serif;
    background: #1d2026;
    box-sizing: border-box;
}
.dark-mode {
    background: red;
    transition: 1s;
}
/* Aspectul lui .Welcome*/
/*aspect of .welcome*/

.Welcome h1{
    user-select: none;
    font-size: 12.5rem;
    letter-spacing: 0rem;
    position: absolute;
    margin: 0;
    top: 40%;
    left: 51%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: -webkit-linear-gradient(320deg,rgb(100, 38, 38), rgba(84, 0, 153, 0.39));
    -webkit-background-clip: text;
    background-clip: border;
    -webkit-text-fill-color: transparent;
    transition: 0.7s;
    white-space: nowrap;
    overflow-x: auto;
}

/* CSS-ul pentru animatie*/
/*the css for changePose, name duration etc*/

.Welcome h1{
    animation-name: changePose;
    animation-duration: 1s;
    animation-delay: 6s;
    animation-iteration-count: 1;
    animation-fill-mode: forwards;
}

/*Animatia de la hover si background-ul oferit*/
/*the hover animation which changes the size and letter-spacing*/

.Welcome h1:hover {
    font-size: 13.5rem;
    position: absolute;
    letter-spacing: 1rem;
    top: 40%;
    left: 51%;
    margin: 0;
    background-size: cover;
    transform: translate(-50%, -50%);
    background: src('https://f.vividscreen.info/soft/7e879fb5d5b73ef41cffd9032e9ad55e/Red-Sky-1920x1200.jpg');/*ignore this background*/
    -webkit-text-fill-color: transparent;
    background-clip: border-box;
    -webkit-background-clip: text;
}
/*Keyframurile de la animatia de tranzitie din mjloc
catre top*/
/* the keyframes to change that apearance of h1, from 12.5rem to 5rem*/

@keyframes changePose {
    from {
        position: absolute;
    }
    to {
        position: absolute;
        font-size:5rem;
        align-items: center;
        top: 8%;
    } 
}

/*Animatia efectului "ellipsis" (cele 3 puncte) loading*/
/*ellipsis animation*/

.Welcome h1::after {
    overflow: hidden;
    display: inline-block;
    vertical-align: bottom;
    -webkit-animation-timing-function: steps(4, end);
    animation-timing-function: steps(4, end);
    -webkit-animation: ellipsis;
    animation: ellipsis;
    animation-duration:1s;
    animation-iteration-count: 4;
    animation-delay: 1s;
    content: "26"; /*codul ascii pentru "..."*/
    width: 0px;
}

@keyframes ellipsis {
    to{
        width: 12.5rem;
    }
}

@-webkit-keyframes ellipsis {
    to {
    width: 12.5rem;    
    }
}

.btn{
    user-select: none;
    font-size: 2rem;
    color: #29313f;
    display: inline-flex;
    background: transparent;
    align-items: center;
    justify-content: center;
    border-radius: 5.5%;
    border: none;
    text-decoration: none;
    margin-top: 28%;
    margin-left: 47%;
}

.btn:hover{
    color: #303949;
    text-decoration: none;
    background: transparent;
    align-items: center;
}

/*Adaptarea ecranului la dfierite dimensiuni*/
/*Addaption the diffrent screen resolutin*/

@media only screen and (max-width: 800px) {
    .Welcome h1{
      font-size: 5rem;
      letter-spacing: 0;
    }
    .Welcome h1:hover{
        font-size: 6rem;
        letter-spacing: 0.4rem;
    }
    @keyframes changePose {
        from{
            font-size: 5rem;
            transition: 0.7s;
        }
        to{
            font-size: 3rem;
            top: 7%;
        }
    }
    
    @keyframes ellipsis {
        to{
            width: 5rem;
        }
    }
    @-webkit-keyframes ellipsis {
        to {
        width: 5rem;    
        }
    }
    .btn{
        font-size: 2rem;
        margin-top: 50%;
        margin-left: 44%;
    }
}
<!DOCTYPE html>
<html lang="en">
<head>
    <title>welcome</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/style.css">
</head>
<body> 
    <header>
    /*<nav> 
        <img src="" class="logoTemp">
    </nav>*/
    </header>
    <div class="Welcome"><h1>welcome</h1></div>
    <div>
    <button class =btn onclick="myFunction()">Epic mode</button>
    </div>
<script>
    function myFunction() {
       var element = document.body;
       element.classList.toggle("dark-mode");
    }
</script>
</body>
</html>

我建议你不要使用 <h1> 标签,因为它在不同的浏览器中有默认的 CSS 值。尽量换成普通的<div>,明确自己想要的样式