gpt4 book ai didi

html - h1 行高或悬停颜色变化时的高度问题

转载 作者:行者123 更新时间:2023-11-28 01:28:19 25 4
gpt4 key购买 nike

我想在悬停 h1 时改变颜色,如下面的代码所示。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style>
h1 {color:#aef;font-size: 14em;line-height: 0.1;}
h1:hover {color: #ff9224;}
</style>
</head>
<body>
<h1>More</h1>
</body>
</html>

(代码也在JS Bin中。)

但是,我只希望鼠标悬停在字母 上时颜色发生变化,例如图片中绿线下方的字母区域。我曾尝试将 line-heightheight 设置为非常小的值,但都没有生效。

我应该更改其他内容吗?还是为了方便用p代替h1

hovering green line on the very top of letter

最佳答案

如果有帮助,试试我创建的这个片段

.border {
overflow: hidden;
}
h1 {
color: #aef;
font-size: 14em;
line-height: 163px;
margin: 0;
}
h1:hover {
color: #ff9224;
}
<div class="border">
<h1>More</h1>
</div>

关于html - h1 行高或悬停颜色变化时的高度问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31209033/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com