[英]styling css unordered lists as image
I was trying to crate unordered lists and change marker to image.我试图创建无序列表并将标记更改为图像。 But my marker is don't showing up.
但是我的标记没有出现。 I don't know what I did wrong.
我不知道我做错了什么。 I need some help.
我需要一些帮助。
This is my CSS code:这是我的 CSS 代码:
ul {
list-style-type: none;
padding-left: 50px;
margin-top: 22px;
}
li {
position: relative;
font-size: 17px;
font-weight: 300;
line-height: 24px;
margin-bottom: 10px;
}
li::before {
content: '';
display: block;
position: absolute;
left: -32px;
top: 3px;
width: 21px;
height: 20px;
background: url('../icons/icon_blue_list.svg') center (center / cover) no-repeat;
}
It should be as follows.应该如下。 Also I don't think you need a::before psudo effect
另外我认为你不需要 a::before psudo 效果
background: url('../icons/icon_blue_list.svg') no-repeat left top;
You should also use the list-style-image property instead您还应该使用 list-style-image 属性
The problem was a syntax problem.问题是语法问题。 Using
center/cover no-repeat
would fix it.使用
center/cover no-repeat
可以解决这个问题。
ul { list-style-type: none; padding-left: 50px; margin-top: 22px; } li { position: relative; font-size: 17px; font-weight: 300; line-height: 24px; margin-bottom: 10px; } li::before { content: ''; display: block; position: absolute; left: -32px; top: 3px; width: 21px; height: 20px; /* Changed "center (center / cover) no-repeat" */ background: url('https://picsum.photos/200') center/cover no-repeat; }
<ul> <li>1</li> <li>1</li> <li>1</li> </ul>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.