Replace ul bullets with a button

2019-07-30 01:36发布

Is it possible to replace ul bullets with a button? I know you can change to images with CSS but if I wanted an actual element?

2条回答
\"骚年 ilove
2楼-- · 2019-07-30 02:10

This isn't possible as you asked, but you could, perhaps, emulate it:

<ul>
    <li><button>some button text</button>List-element text.</li>
</ul>

And the following CSS:

ul, li {
    list-style-type: none;
}

li {
    padding-left: 0;
    margin-left: 0;
}

li button {
    margin-right: 2em;
}

JS Fiddle demo.

The success, or applicability, of this approach does, of course, depend entirely on your use-case which your question omits. With more detail, perhaps this answer can become more useful.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-07-30 02:17

No, with CSS you can style the bullets or have them omitted, and you can have generated content instead, but generated content introduces just a pseudo-element with some content, not a real button element for example.

If you need to have an ul element in markup (I wonder why), then you could use some JavaScript that injects button elements (and CSS that hides the bullets). But assuming that I guess your intentions correctly, why not use just a table with buttons in one column, associated content in another, or maybe just div elements with content starting with a button element?

查看更多
登录 后发表回答