Skip to content

Commit 44912b6

Browse files
committed
style(table): add overflow-x for mobile tables with wrapper
1 parent 76aaf58 commit 44912b6

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

static/js/table-wrap.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
document.querySelectorAll("article[itemprop='articleBody'] > table").forEach(function (table) {
2+
var wrapper = document.createElement("figure");
3+
wrapper.style.overflowX = "auto";
4+
wrapper.style.webkitOverflowScrolling = "touch";
5+
wrapper.style.margin = "0";
6+
table.parentNode.insertBefore(wrapper, table);
7+
wrapper.appendChild(table);
8+
});

templates/_base.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
{% if config.extra.theme %}
155155
<script src="{{ get_url(path='js/toggle-theme.js', trailing_slash=false) | safe }}"></script>
156156
{% endif %}
157+
<script defer src="{{ get_url(path='js/table-wrap.js', trailing_slash=false) | safe }}"></script>
157158
{% include "partials/latex.html" %}
158159
{% include "partials/search.html" %}
159160
{% endblock scripts %}

0 commit comments

Comments
 (0)