fix(чат): таблица занимает всю ширину ленты и нигде не прокручивается вбок; версия 2026-11-18d
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
+21
-23
@@ -142,6 +142,12 @@ button { font-family: inherit; }
|
||||
.requisites { text-align: center; font-size: .72rem; color: var(--text-muted); margin-top: .2rem; line-height: 1.45; }
|
||||
.landing-foot { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1.4rem 0 1.8rem; border-top: 1px solid var(--border-light); font-size: .78rem; color: var(--text-muted); }
|
||||
.landing-foot a { color: var(--text-muted); }
|
||||
/* На телефоне таблица тоже без прокрутки вбок: уменьшаем шрифт и отступы ячеек,
|
||||
чтобы колонки не складывались в столбик из букв (сказал Хозяин 18.11). */
|
||||
@media (max-width: 640px) {
|
||||
.msg-ai .table-wrap { font-size: .74rem; }
|
||||
.msg-ai .table-wrap th, .msg-ai .table-wrap td { padding: .3rem .25rem; }
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.hero-grid, .login-grid { grid-template-columns: 1fr; gap: 1.4rem; }
|
||||
.pains, .steps { grid-template-columns: 1fr; }
|
||||
@@ -322,7 +328,7 @@ button { font-family: inherit; }
|
||||
/* Таблица живёт в своём окне с ограничением высоты: иначе её горизонтальная полоса
|
||||
оказывалась внизу длинной таблицы, и до неё надо было прокрутить всю ленту
|
||||
(сказал Хозяин 18.11). С max-height обе полосы всегда у края видимой рамки. */
|
||||
.msg-ai .table-wrap { overflow: auto; max-height: min(60vh, 560px); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; margin: .5rem 0; border: 1px solid var(--border); border-radius: 8px; scrollbar-width: thin; scrollbar-color: var(--text-muted) transparent; }
|
||||
.msg-ai .table-wrap { overflow-y: auto; overflow-x: hidden; max-height: min(60vh, 560px); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; margin: .5rem 0; border: 1px solid var(--border); border-radius: 8px; scrollbar-width: thin; scrollbar-color: var(--text-muted) transparent; }
|
||||
/* Полоса прокрутки у таблицы должна быть видна в обеих темах: общий «тихий»
|
||||
скроллбар в тёмной теме сливался с фоном, и казалось, что таблица обрезана
|
||||
(жалоба Хозяина 18.11). */
|
||||
@@ -330,14 +336,19 @@ button { font-family: inherit; }
|
||||
.msg-ai .table-wrap::-webkit-scrollbar-thumb { background: var(--text-muted); border: 2px solid transparent; background-clip: padding-box; border-radius: 6px; }
|
||||
.msg-ai .table-wrap::-webkit-scrollbar-thumb:hover { background: var(--text); }
|
||||
/* Таблица хочет больше места — сообщение расширяется на всю ленту (сказал Хозяин 18.11). */
|
||||
.msg-ai.has-table { max-width: 100%; }
|
||||
.msg-table-hint { font-size: .75rem; color: var(--text-muted); margin-left: .5rem; white-space: nowrap; }
|
||||
.msg-ai table { border-collapse: collapse; margin: 0; font-size: .82rem; width: auto; min-width: 100%; }
|
||||
.msg-ai.has-table { width: 100%; max-width: 100%; }
|
||||
|
||||
/* Таблица всегда укладывается в ширину окна: горизонтальной прокрутки нет вовсе
|
||||
(распоряжение Хозяина 18.11). Колонки делят ширину поровну, длинные токены переносятся. */
|
||||
.msg-ai table { border-collapse: collapse; margin: 0; font-size: .82rem; width: 100%; }
|
||||
/* Внутри таблицы слова не рвём по буквам: при узкой ленте колонки сжимались до одной
|
||||
буквы («Н а и м е н о в а н и е»), вместо того чтобы дать таблице прокрутку.
|
||||
Минимальная ширина колонки держит слово целиком, а широкая таблица крутится вбок. */
|
||||
.msg-ai .table-wrap table { word-break: normal; overflow-wrap: break-word; }
|
||||
.msg-ai .table-wrap th, .msg-ai .table-wrap td { min-width: 5em; }
|
||||
.msg-ai .table-wrap table { word-break: normal; overflow-wrap: anywhere; }
|
||||
/* Числовые ячейки в обычной ленте не переносятся (nowrap), но в таблице это выталкивало
|
||||
содержимое за край окна. Внутри окна числа переносятся — зато нет прокрутки вбок. */
|
||||
.msg-ai .table-wrap .num, .msg-ai .table-wrap th.num { white-space: normal; overflow-wrap: anywhere; }
|
||||
.msg-ai .table-wrap th, .msg-ai .table-wrap td { min-width: 0; }
|
||||
.msg-ai .table-wrap thead th { position: sticky; top: 0; background: var(--ai-bg); z-index: 1; }
|
||||
.msg-ai th, .msg-ai td { border: 1px solid var(--border-light); padding: .35rem .6rem; text-align: left; vertical-align: top; white-space: normal; max-width: 360px; }
|
||||
.msg-ai th { background: var(--bg); font-weight: 600; position: sticky; top: 0; }
|
||||
@@ -926,35 +937,22 @@ function enhanceTables(container) {
|
||||
container.classList.add('has-table');
|
||||
// Подсказка «прокрутите вбок» — только если таблица правда шире обёртки.
|
||||
// Меряем после вставки в страницу: до неё размеры нулевые.
|
||||
requestAnimationFrame(updateTableHints);
|
||||
requestAnimationFrame(updateTableHeights);
|
||||
});
|
||||
}
|
||||
|
||||
// Обновляет подсказки у всех таблиц: нужна и после вставки, и после смены ширины окна —
|
||||
// иначе на узком окне таблица молча обрезается без объяснения (жалоба Хозяина 18.11).
|
||||
function updateTableHints() {
|
||||
function updateTableHeights() {
|
||||
// Высота окна таблицы ограничена ВИДИМОЙ частью ленты, а не окном браузера: иначе
|
||||
// нижняя полоса окна уезжала под поле ввода, и до неё снова надо было скроллить ленту
|
||||
// (сказал Хозяин 18.11). Пересчитываем и при смене ширины/высоты окна.
|
||||
// низ окна уезжал под поле ввода (сказал Хозяин 18.11). Пересчитываем при смене окна.
|
||||
const area = document.getElementById('messages');
|
||||
const предел = area ? Math.max(220, area.clientHeight - 90) : 480;
|
||||
document.querySelectorAll('.msg-ai .table-wrap').forEach(wrap => {
|
||||
wrap.style.maxHeight = предел + 'px';
|
||||
const bar = wrap.previousElementSibling;
|
||||
if (!bar || !bar.classList.contains('msg-table-bar')) return;
|
||||
const hint = bar.querySelector('.msg-table-hint');
|
||||
const wide = wrap.scrollWidth > wrap.clientWidth + 1;
|
||||
if (wide && !hint) {
|
||||
const s = document.createElement('span');
|
||||
s.className = 'msg-table-hint';
|
||||
s.textContent = '↔ Прокрутите таблицу вбок';
|
||||
bar.appendChild(s);
|
||||
} else if (!wide && hint) {
|
||||
hint.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
window.addEventListener('resize', updateTableHints);
|
||||
window.addEventListener('resize', updateTableHeights);
|
||||
|
||||
// --- Генерация НАСТОЯЩЕГО .xlsx (OOXML zip) без внешних библиотек. ---
|
||||
// Трюк «HTML c расширением .xls» открывался как простыня тегов в Numbers/
|
||||
|
||||
Reference in New Issue
Block a user