Skip to content

Instantly share code, notes, and snippets.

@yuchuanxi
Created June 30, 2014 05:01
Show Gist options
  • Save yuchuanxi/99f3f4bf27f1f68bc52a to your computer and use it in GitHub Desktop.
Save yuchuanxi/99f3f4bf27f1f68bc52a to your computer and use it in GitHub Desktop.
CSS实现li元素的value属性效果(>=IE8)
.list {
list-style: none;
padding: 0 0 0 13px;
counter-reset: item 2;
}
.list li {
position: relative;
padding: 0 0 0 20px;
counter-increment: item 1;
}
.list li:before {
display: inline-block;
position: absolute;
left: 0px;
top: 0;
content: counter(item)'.'
}
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="CSS实现li元素的value属性效果(>=IE8)" />
<meta charset="utf-8">
<title>CSS实现li元素的value属性效果(>=IE8)</title>
</head>
<body>
<h2>counter()的兼容性为 >= IE8</h2>
<ol class="list">
<li value="3">333 - css</li>
<li>444 - css</li>
<li>555 - css</li>
<li>666 - css</li>
<li>777 - css</li>
</ol>
<ol>
<li value="3">333 - html</li>
<li>444 - html</li>
<li>555 - html</li>
<li>666 - html</li>
<li>777 - html</li>
</ol>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment