Простое решение на CSS для адаптивной страницы.
/*Адаптивная таблица*/
@media screen and (max-width: 600px) {
table {width:100%;}
thead {display: none;}
tr:nth-of-type(2n) {background-color: inherit;}
tr td:first-child {background: #f0f0f0; font-weight:bold;font-size:1.3em;}
tbody td {display: block; text-align:center;}
tbody td:before {
content: attr(data-th);
display: block;
text-align:center;
}
}Способ второй - обернуть таблицу в .table-cover:
@media screen and (max-width: 1035px) { // на всех экранах шириной до 1035 пикселей
.table-cover {
width: 100%;
overflow: auto;
margin: 0 0 1em;
}
}Обернуть автоматически:
add_action( 'wp_footer', 'art_responsive_tables' );
function art_responsive_tables() {
if ( is_singular() ) {
?>
<script>
jQuery(document).ready(function ($) {
$('article table').wrap('<div class="table-cover"></div>');
});
</script>
<style>
@media screen and (max-width: 1035px) {
.table-cover {
width: 100%;
overflow: auto;
margin: 0 0 1em;
}
}
</style>
<?php
}
}