[英]CSS What am I doing wrong? background image in unordered lists
.navbar {
position:relative;
height: 50px;
}
ul {
height:inherit;
position:absolute;
top:19%;
}
ul li {
height:inherit;
padding: 10px 1px 10px 1px;
display:inline;
font-size:1.3125em;
transition: all 0.4s ease;
}
ul li:hover {
background-color: #0E0E0E;
background: url(img/a.svg) no-repeat;
background-position: 0px 5px;
}
So, basically, i would like to apply an image to the highlighted unordered list items, but this image NEVER appears, how is that? 因此,基本上,我想将图像应用于突出显示的无序列表项,但是此图像从不出现,那怎么办?
You've got the image url incorrect. 您的图片网址不正确。 Either that or you have some other styles conflicting or your
CSS
does not correctly match your HTML
. 要么是您的样式发生冲突,要么是
CSS
不能正确匹配HTML
。
See this fiddle. 看到这个小提琴。 Using what I'd expect your
HTML
structure to be, it works fine using an external image; 使用我期望的
HTML
结构,可以使用外部图像正常工作;
If you also want the background colour to be applied as well as the picture you'd need to change your CSS
to this; 如果您还希望应用背景颜色以及图片,则需要将
CSS
更改为此。
ul li:hover {
background-color: #0E0E0E;
background-image: url(img/a.svg);
background-repeat: no-repeat;
background-position: 0px 5px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.