Help us understand the problem. What is going on with this article?

olタグのナンバリングをカッコつきにする

More than 3 years have passed since last update.

単純に(1)になればいい

kakko.css
ol {
  list-style-type: none;
}

ol li {
  counter-increment: cnt;
}

ol li:before {
  content: "(" counter(cnt) ") ";
}

()部分が、list-style-position:insideてきな扱いになるのが嫌

kakko-outside.css
ol {
  list-style-type: none;
  margin-left: 3em; /* いい塩梅の幅を設定したまえ */
}

ol li {
  counter-increment: cnt;
}

ol li:before {
  content: "(" counter(cnt) ") ";
  display:inline-block;
  margin-left:-3em; /* いい塩梅の幅を設定したまえ */
  width: 3em; /* いい塩梅の幅を設定したまえ */
}

ol > li の start属性を使いたい

以下のhtmlをカッコつきで表示したいとき、第二シーズンのstart属性が無視されて、1~の表示になっちゃう。

kakko.html
<h1>第一シーズン</h1>
<ol start="1">
  <li>マックス誕生</li>
  <li>殺人スポーツ・レイキング</li>
  <li>謎の人体バンク</li>
</ol>

<h1>第二シーズン</h1>
<ol start="4">
  <li>天才少年養成アカデミー</li>
  <li>美人伝道師の誘惑</li>
  <li>宿敵グロスバーグの逆襲</li>
</ol>

しょうがないので、jQueryで無理やり書き換えちゃう。

kakko.js
$("ol").each(function() {
  var start = $(this).attr("start");
  start = start - 1;
  $(this).css({
    'counterReset': 'cnt ' + start
  });
});

しっかり見てないけど、IE8以降ぐらいなら動くんじゃないかな。

関連リンク

イカ
アイドル
夢がひろがる

zoker
諦めベース開発を行う40代。欲しいものは既得利権。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした