How to add brackets (a) to ordered list? compatibl

2019-01-23 04:10发布

I have to show like

(a)

(b)

(c)

Update:

I found a CSS way

ol {list-style-type: none;}
li:before {content: "(" counter(section, lower-alpha) ") ";}
li { counter-increment: section;}

but it not works in IE 7 and lower.

标签: jquery css xhtml
8条回答
Explosion°爆炸
2楼-- · 2019-01-23 04:16

I use this code snippet in mediawiki with CSS enabled. I am not sure whether this will work in older versions of IE...

{{#css:
  .laparent ol { counter-reset: item }
  .laparent li { display: block ; counter-increment: item; }
  .laparent li:before { content: " ("counter(item,lower-alpha)") "; }
}}
<ol class=laparent>
   <li> this is the first item;
   <li> this is the second item; or
   <li> this is the third item.
</ol>

Outputs:

(a) this is the first item;
(b) this is the second item; or
(c) this is the third item. 
查看更多
地球回转人心会变
3楼-- · 2019-01-23 04:18

I instead made paragraphs. I indented the paragraph and then pulled out the first line, using a text-indent and numbered these myself.

.list_indent {
margin-left:48px;
}
.list_indent p {
text-indent:-26px;
}

<div class="list_indent">  
<p> (1)&nbsp;&nbsp;The recruitment report and a copy of the blah and blah and blah and blah and blah and blah and blah and blah.;
</p>   
<p> (2)&nbsp;&nbsp;A copy of the blah and blah and blah and blah and blah and blah and blah and blah.
</p>     
<p> (3)&nbsp;&nbsp;Recruitment.
</p>   
</div>
查看更多
Ridiculous、
4楼-- · 2019-01-23 04:21

Since CSS3 the problem seems solved:

style="list-style-type: parenthesized-lower-latin;"

http://www.w3.org/TR/2011/WD-css3-lists-20110524/

查看更多
Explosion°爆炸
5楼-- · 2019-01-23 04:23

There's no built-in way to do this. Which means you enter the land of (fun) hacks.

You could try a background image of two parentheses.

查看更多
Rolldiameter
6楼-- · 2019-01-23 04:27

Or you can simply add the text count manually without having yo worry about browser fallbacks. Works in any browser!

ul.abc-list {
  list-style: none;
  padding-left: 30px;
}
ul.abc-list > li > span.counter {
  position: absolute;
  margin-left: -20px;
  /*if you want to right align the text
   * 
   * width: 15px;
   * text-align: right;
   */
}
<ul class="abc-list">
  <li><span class="counter">a)</span> One</li>
  <li><span class="counter">b)</span> Two</li>
  <li><span class="counter">c)</span> Three</li>
  <li><span class="counter">d)</span> Four</li>
  <li><span class="counter">e)</span> Five</li>
  <ul>

查看更多
神经病院院长
7楼-- · 2019-01-23 04:31

You can't get (a) (b) (c).

You can however get the letter without the brackets:

<ul style="list-style-type: lower-latin;">...</ul>

See http://www.w3schools.com/CSS/tryit.asp?filename=trycss_list-style-type_all

查看更多
登录 后发表回答