正如您在屏幕截图中看到的那样,我有一个无序列表。现在这个列表的div
有一个背景图片。我想要做的是每当将鼠标悬停在列表项上时更改背景图像。请注意,每个项目都应将背景更改为不同的图像。我该怎么做呢?我只找到答案如何更改为单个而不是多个图像。在列表项上悬停时更改背景图像
下面是截图。
我已经徘徊在列表中的第一项。
div
的CSS:
.body {
display: block;
float: left;
background-image: url("bgdef.jpg");
background-repeat: no-repeat;
position: static;
width: 100%;
height: auto;
margin: 0;
}
.menu {
width: 250px;
padding: 0;
margin: 100px 0px 33% 75%;
list-style-type: none;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-user-drag: none;
}
.menu a:link,
a:visited,
a:hover,
a:active {
text-decoration: none;
bottom: auto;
padding-bottom: auto;
text-shadow: none;
}
.menu li {
background-color: white;
margin: 10px;
padding: 3px 0 3px 10%;
border-radius: 10PX 0 0 10px;
font-size: 20px;
}
.menu li:hover {
background-color: green;
margin-right: 18px;
margin-left: 1px;
}
我认为你必须使用JavaScript。 –
现在这是一个详尽的解释。 QQ –
你可以发布一个codepen或小提琴吗? – NooBskie