FRONTENDINTERVIEW Telegram 4367
Как можно расставить автоматическую нумерацию элементов, не относящихся к спискам при помощи CSS?

В следующем примере показано простое использование функции counter():
<section class="table-of-contents">
<h1 class="title">Оглавление</h1>
<h2 class="chapter">HTML и CSS</h2>
<h2 class="chapter">Создание стилей и таблиц стилей</h2>
<h2 class="chapter">Селекторы: выбор форматируемых элементов</h2>
<h2 class="chapter">Механизм наследования стилей</h2>
<h2 class="chapter">Управление сложной структурой стилей: каскад</h2>
<h2 class="chapter">Поля, отступы, границы</h2>
</section>


На элементе <section> создаём счётчик с именем chapter и начальным значением 0:
.table-of-contents {
counter-reset: chapter 0;
}


Устанавливаем увеличение значения счётчика сhapter, используя свойство counter-increment. Далее подставляем значение счётчика chapter через функцию counter():
.chapter {
counter-increment: chapter 1;
}

.chapter::before {
content: "Глава "counter(chapter) ": ";
}


👉 @frontendInterview



tgoop.com/frontendInterview/4367
Create:
Last Update:

Как можно расставить автоматическую нумерацию элементов, не относящихся к спискам при помощи CSS?

В следующем примере показано простое использование функции counter():

<section class="table-of-contents">
<h1 class="title">Оглавление</h1>
<h2 class="chapter">HTML и CSS</h2>
<h2 class="chapter">Создание стилей и таблиц стилей</h2>
<h2 class="chapter">Селекторы: выбор форматируемых элементов</h2>
<h2 class="chapter">Механизм наследования стилей</h2>
<h2 class="chapter">Управление сложной структурой стилей: каскад</h2>
<h2 class="chapter">Поля, отступы, границы</h2>
</section>


На элементе <section> создаём счётчик с именем chapter и начальным значением 0:
.table-of-contents {
counter-reset: chapter 0;
}


Устанавливаем увеличение значения счётчика сhapter, используя свойство counter-increment. Далее подставляем значение счётчика chapter через функцию counter():
.chapter {
counter-increment: chapter 1;
}

.chapter::before {
content: "Глава "counter(chapter) ": ";
}


👉 @frontendInterview

BY Frontend Interview - собеседования по Javascript / Html / Css




Share with your friend now:
tgoop.com/frontendInterview/4367

View MORE
Open in Telegram


Telegram News

Date: |

In the “Bear Market Screaming Therapy Group” on Telegram, members are only allowed to post voice notes of themselves screaming. Anything else will result in an instant ban from the group, which currently has about 75 members. The main design elements of your Telegram channel include a name, bio (brief description), and avatar. Your bio should be: How to Create a Private or Public Channel on Telegram? During a meeting with the president of the Supreme Electoral Court (TSE) on June 6, Telegram's Vice President Ilya Perekopsky announced the initiatives. According to the executive, Brazil is the first country in the world where Telegram is introducing the features, which could be expanded to other countries facing threats to democracy through the dissemination of false content. Choose quality over quantity. Remember that one high-quality post is better than five short publications of questionable value.
from us


Telegram Frontend Interview - собеседования по Javascript / Html / Css
FROM American