【发布时间】:2021-10-18 07:24:23
【问题描述】:
我想将:hover 伪类添加到h1。首先,background-color 必须等于 = 0%(我添加了一种颜色进行测试,但最后背景颜色将是白色)然后当悬停到 h1 时,background-color 必须是灰色且大小为100% 100%。我不能那样做。 :')
.back{
border: 1px solid black;
width: 250px;
background-color: tomato;
height: 100px;
background-size: 0% 100%;
background-repeat: no-repeat;
transition: 1s all;
}
.back:hover{
background-color: gray;
background-size: 100% 100%;
}
<h1 class="back"></h1>
【问题讨论】:
-
background-size属性指定背景图像的大小。 -
不,我记得!有人这样做是为了输入。但我找不到... :(
-
请更好地描述你想要什么。正如上面提到的@TechySharnav,
background-size指定背景图像的大小。要更改框大小吗? -
好的。 stackoverflow.com/questions/7861648/… 我想为背景颜色做这个。 ^^