我在徘徊为什么我的代码不可以过渡和过渡,而我却找不到答案。 我敢肯定,与其他代码相比,在工作效率方面存在一些错误,但我很难找到它。这是我的第一篇文章,非常抱歉“愚蠢的问题”
<!DOCTYPE html>
<html lang="en">
<head>
<style>
h1 {font-size: 40px;text-align: center;color: crimson;margin:0 10% 20px 10%;padding-bottom: 15px;border-bottom: 2px solid crimson;}
h1:hover {font-size: 45px;transition: 0.3s;}
</style>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Simple Text</h1>
</body>
</html>
我认为您正在尝试实现这样的目标。
which is to apply that transition initially on
h1
and not only in:hover
.都是正确的,但是您只需要将转换放在h1中,而不是h1:hover中即可。
因此,将其更改为此,它应该起作用: