简体   繁体   English

列表样式图像不起作用

[英]list-style-image is not working

I am trying to create custom bullet points and it is not working.我正在尝试创建自定义项目符号,但它不起作用。

This is my HTML.这是我的 HTML。

<div id="services">
    <ul id="serviceText">
        <h2 id="serviceHeader"><strong>Services I Offer:</strong></h2>
        <li>Intros</li>
        <li>Transitions</li>
        <li>Lower Third Titles</li>
        <li>Web Page Design</li>
        <li>and more...</li>                        
    </ul>
</div>

This is my CSS这是我的 CSS

ul#serviceText {
    list-style-image: url(images/checkmark.gif);
    font-size: 14px;
    float: right;
    padding-top: 5px;
    color: white;
}

My site is located here xdtrammell.com/lol if it helps you to see all my code.我的网站位于这里 xdtrammell.com/lol 如果它可以帮助您查看我的所有代码。

change your selector to ul#serviceText li .将您的选择器更改为ul#serviceText li Also keep in mind that you can't include h2 element in ul .还要记住,您不能在ul包含h2元素。 Is not valid html.无效的 html。

Specifically I think you're trying to create custom bullets that are images, here is how I would do it.具体来说,我认为您正在尝试创建作为图像的自定义项目符号,这是我的做法。

The CSS CSS

.list {
  margin: 0;
  padding: 0;
}

.list-li {
  background: url('../directory/your image here.jpg') no-repeat top left;
  margin: 0;
  padding: 4px 0 4px 20px;
  list-style: none;
}

The key thing to note is the background image is in the top left, so take that into consideration when you adjust your padding.需要注意的关键是背景图像位于左上角,因此在调整填充时要考虑到这一点。 Padding is: Top, Right, Left, Bottom.填充是:顶部,右侧,左侧,底部。

The HTML HTML

<ul class="list">
  <li class="list-item">lorem ipsum</li>
  <li class="list-item">lorem ipsum</li>
</ul>

I hope this helps!我希望这有帮助!

You're far better of using a CCS background for your list items than using list-style-image .为列表项使用 CCS 背景要比使用list-style-image好得多。 You get far greater control over the positioning of the graphic and the spacing of the text.您可以更好地控制图形的定位和文本的间距。

See: http://preview.moveable.com/JM/ilovelists/请参阅: http : //preview.moveable.com/JM/ilovelists/

Does it need the ../ before the image URL so it knows to go up a directory?它是否需要在图像 URL 之前使用 ../ 以便它知道向上一个目录? In other words, does your image exist in the top level directory or in one of the next-levels?换句话说,您的图像是否存在于顶级目录或下一级目录中? If it doesn't exist in the top level then it needs "../"如果它不存在于顶层,那么它需要“../”

只需像这样更改 URL 中图像文件夹的路径( ../images/checkmark.gif),“li 标签元素就足以作为选择器。

li {list-style-image: url(../images/checkmark.gif);}

我的情况是,当list-style: inside未设置时,项目符号被隐藏或不可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM