是否可以向(多)markdown元素添加id或类?
例如一张表、一段代码或一块代码?
我想用css设计一个表格的样式,但不包括以下工作:
[captionid][This is the caption, not the table id]
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
[captionid][This is the caption, not the table id]
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
[tablecaption](#tableid)
<div class="special_table">
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
</div>
在网上找不到其他内容。。
我不是指github或stackoverflow口味的降价。
为了CSS的目的,您可以向上一个元素添加一个id,然后使用选择器来更改下面的元素。
降价如下:
<div class="special_table"></div>
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
CSS如下:
div.special_table + table tr:nth-child(even) {background: #922}
您可以将自定义类或id放在元素后面的花括号中,将其添加到元素中,如下所示:{#id .class}
例如:
[Read more](http://www.stackoverflow.com "read more"){#link-sf .btn-read-more}
将呈现如下:
<a href="http://www.stackoverflow.com" title="read more" id="link-sf" class="btn-read-more">Read more</a>
您可以参考https://michelf.ca/projects/php-markdown/extra/#spe-属性
经过一些研究,我提出了一个简单而直接的解决方案:)
我将表放在两个HTML占位符之间,并使用jQuery对它们进行微调,并且只对需要的进行微调:
表格开头
<div class="tables-start"></div>
表
id | name
---|---
1 | London
2 | Paris
3 | Berlin
表格末尾
<div class="tables-end"></div>
jQuery:通过添加类来微调表
<script type="text/javascript">
(function() {
$('div.tables-begin').nextUntil('div.tables-end', 'table').addClass('table table-bordered');
})();
</script>
我只使用了文档,解决方案有点不同。姜给我指明了正确的方向。这对我起到了作用:
[[2]](references#2){: #references-2 }
呈现为:
<a href="references#2" id="references-2">[2]</a>