1
내 HTML 문서에 표 번호를 추가하고 CSS를 사용하는 것이 좋습니다. 우리는 그림 번호 등을 추가 할 수 있지만, "표 - 1"형식으로 표에 번호를 추가하여 표 앞에 표시 할 수있는 방법을 찾을 수 없다는 것을 알고 있습니다.CSS를 사용하여 표 자동 번호 매기기
다음은 내 코드이지만 테이블 머리 다음에 테이블 번호를 넣습니다.
HTML :
<table class="table-bordered table-hover">
<thead>
<tr>
<th scope="col">Cell 1 Head</th>
<th scope="col">Cell 2 Head</th>
<th scope="col">Cell 3 Head</th>
</tr>
</thead>
<tbody>
<tr>
<td>Praesent ac risus malesuada</td>
<td>sapien quis</td>
<td>eget ipsum</td>
</tr>
</tbody>
</body>
</html>
CSS :
table{
counter-reset:section 1;
}
table:before{
content:"Table - " counter(section);
}
출력 :
| 셀 1 헤드 | | 셀 2 헤드 | | 셀 2 헤드 |
표 -
1
... ..
감사합니다. 내가 원했던 것. 그러나 캡션이 중앙에 나타나기 때문에 캡션 속성을 아래와 같이 수정했습니다. caption :: before { counter-increment : section; 콘텐츠 : "테이블 -"카운터 (섹션); \t float : left; \t font-family : 'Roboto', sans-serif; \t 글꼴 크기 : 12px; \t font-weight : 100; }' – bbh