[英]Using psuedo elements for the style of an ordered list, while preserving indentation
I have a situation where the CMS is generating a list of the form 我遇到了CMS正在生成表单列表的情况
<ul>
<li>
<a>Here's list item 1, which will wrap onto the next next due to the size of the ul element containing it</a>
</li>
<li>
<a>Here's list item 2, which will wrap onto the next next due to the size of the ul element containing it</a>
</li>
<li>
<a>Here's list item 3, which will wrap onto the next next due to the size of the ul element containing it</a>
</li>
</ul>
and I need the client wants the list style to be '>'
characters and be a different color than the text. 并且我需要客户希望列表样式为
'>'
字符,并且颜色与文本不同。 So I decided to use the classic pseudo-element hack, but now the problem is that I want the text to be aligned when it wraps to the next line, as in normal lists. 因此,我决定使用经典的伪元素hack,但是现在的问题是,我希望文本在换行到下一行时能够对齐,就像在普通列表中一样。 I've tried seemingly every combination of padding/text-indent/margin over the
li
and li:before
elements, but can't get it right. 我似乎尝试了
li
和li:before
元素的padding / text-indent / margin的每种组合,但无法正确完成。
Here's a fiddle of the scenario: 这是方案的一个小提琴:
Could you give your pseudo element a negative margin: 你能给你的伪元素一个负边距吗?
ul > li:before {content: ">";margin-left:-.8em;}
http://jsfiddle.net/t0wxsf0j/1/ http://jsfiddle.net/t0wxsf0j/1/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.