【发布时间】:2015-12-01 22:58:17
【问题描述】:
正如您在屏幕截图中看到的,我有一个无序列表。现在这个列表的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或fiddle吗?
-
添加随机图片来自互联网codepen.io/K4R0L3N45/pen/PPwvzL
标签: javascript jquery html css