<!DOCTYPE html> <html lang="ru"> <head> <meta charset="UTF-8"> <meta name="viewport"…
- User
body { font-family: Arial, sans-serif; padding: 20px; } .grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; transition: all 0.5s ease-out; position: relative; } .card { background-color: #f0f0f0; padding: 20px; position: relative; transition: background-color 0.5s ease, transform 0.3s ease; cursor: pointer; z-index: 1; border-radius: 8px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; } .card .expand-btn { margin-top: 10px; padding: 8px 12px; background-color: #007bff; color: white; border: none; cursor: pointer; transition: background-color 0.3s ease; border-radius: 4px; } .card .expand-btn:hover { background-color: #0056b3; } .card.expanded { background-color: #d0eaff; z-index: 2; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); grid-column: 1 / -1; /* Расширяет карточку на всю ширину грида */ } .card.hidden { opacity: 0; pointer-events: none; transition: opacity 0.3s ease; display: none; } .grid-container:has(.card.expanded) .card:not(.expanded){ opacity: 0.5; pointer-events: none; } .overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); opacity: 0; transition: opacity 0.3s ease; z-index: 1; } .overlay.show { opacity: 1; } </style><script> const overlay = document.querySelector('.overlay'); const gridContainer = document.querySelector('.grid-container'); document.querySelectorAll('.expand-btn').forEach(button => { button.addEventListener('click', (e) => { e.stopPropagation(); const card = button.closest('.card'); if (card.classList.contains('expanded')) { // Свернуть карточку collapseCard(card); } else { // Свернуть любые ранее развернутые карточки const expanded = gridContainer.querySelector('.card.expanded'); if (expanded) { collapseCard(expanded); } // Развернуть текущую карточку expandCard(card); } }); }); // Свернуть карточку function collapseCard(card) { card.classList.remove('expanded'); overlay.classList.remove('show'); const details = card.querySelector('.details'); if (details) details.style.display = 'none'; // Показать все карточки document.querySelectorAll('.card').forEach(c => { c.classList.remove('hidden'); }); } // Развернуть карточку function expandCard(card) { card.classList.add('expanded'); overlay.classList.add('show'); const details = card.querySelector('.details'); if (details) details.style.display = 'block'; // Определить строку, в которой находится карточка const allCards = Array.from(gridContainer.children); const index = allCards.indexOf(card); const computedStyle = getComputedStyle(gridContainer); const columnCount = computedStyle.gridTemplateColumns.split(' ').length; const row = Math.floor(index / columnCount); // Скрыть другие карточки в той же строке allCards.forEach((c, i) => { const currentRow = Math.floor(i / columnCount); if (currentRow === row && c !== card) { c.classList.add('hidden'); } }); } // Свернуть карточку при клике на затемнённый фон overlay.addEventListener('click', () => { const expandedCard = gridContainer.querySelector('.card.expanded'); if (expandedCard) { collapseCard(expandedCard); } }); // Обработка изменения размера окна для корректного скрытия карточек window.addEventListener('resize', () => { const expandedCard = gridContainer.querySelector('.card.expanded'); if (expandedCard) { // Пересчитать и скрыть карточки в текущей строке document.querySelectorAll('.card').forEach(c => c.classList.remove('hidden')); const allCards = Array.from(gridContainer.children); const index = allCards.indexOf(expandedCard); const computedStyle = getComputedStyle(gridContainer); const columnCount = computedStyle.gridTemplateColumns.split(' ').length; const row = Math.floor(index / columnCount); allCards.forEach((c, i) => { const currentRow = Math.floor(i / columnCount); if (currentRow === row && c !== expandedCard) { c.classList.add('hidden'); } }); } }); </script> - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.