修訂答:jsFiddle Pure CSS Solution
這裏是一個修改後的方法是不使用OP的原jQuery框架,這不是一個請求在我以前的答案中得到滿足。該方法使用現有的jQuery爲li
元素應用span span wrapper,因爲直接的HTML修改是不可能的。
這種新方法使用CSS僞選擇:before
和:after
與CSS一起2.1 counter
功能,可以有它的程式化,這樣不需要jQuery的包裝號碼列表。實際上,jsFiddle版本使用Google @ font-face字體顯示數字。
使用CSS計數器功能是通過聲明一個變量名在ul
元素的使用,然後增加在:before
元件的對,以及使用它作爲實際內容完成。
簡單的例子:jsFiddle CSS Counter
HTML:
<ul>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
<li>A numbered list that's stylized!</li>
</ul>
CSS:
ul{
list-style-type: none;
white-space: nowrap;
margin: 0;
padding: 0;
width: 210px;
height: 200px;
overflow: auto;
border: 3px solid royalblue;
/* Setup the counter. */
counter-reset: yourVariableName;
}
li:before{
/* Advance the number. */
counter-increment: yourVariableName;
/* Use the counter number as content. */
content: 'Item ' counter(yourVariableName) ': ';
color: royalBlue;
font-family: 'Impact';
}
關於CSS計數器的更多信息HERE。
我在OP的問題中使用現有框架的原始日期答案如下所示。
我仔細看了一下你的問題,然後又看了看自己的網頁。
這裏是你需要的解決方案: jsFiddle
總之,這是更換CSS規則,使其工作:
#secondary ol {
color:#F60;
margin-bottom:0;
margin-left: 0px; /* Since 'ul,ol{}' setting in line 108 affects this selector, 'margin-left' is redefined. */
list-style-position: inside; /* This will place the number on top and inside of the current color of li */
}
.notes{
color:#333;
width: 230px;
heigh: 50px;
display: inline-block;
vertical-align:text-top;
}
結果:
附加:這種變異例如強調數字:jsFiddle
*你想要什麼樣的數字? – poepje
對不起,不清楚!右側列表中的數字。將編輯我的問題。謝謝。 –