body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; margin: 0; padding: 20px; background-color: #f5f5f5; } .container { max-width: 800px; margin: 0 auto; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 0 10px rgba(0,0,0,0.1); } h1 { color: #2c3e50; text-align: center; border-bottom: 2px solid #3498db; padding-bottom: 10px; } .add-article { background: #f9f9f9; padding: 15px; border-radius: 5px; margin-bottom: 30px; } #article-form { display: flex; flex-direction: column; gap: 10px; } #article-form input, #article-form textarea { padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 16px; } #article-form textarea { min-height: 100px; resize: vertical; } #article-form button { background: #3498db; color: white; border: none; padding: 12px; cursor: pointer; border-radius: 4px; font-size: 16px; transition: background 0.3s; } #article-form button:hover { background: #2980b9; } .articles-container { display: flex; flex-direction: column; gap: 20px; } .article-item { border: 1px solid #ddd; border-radius: 5px; padding: 15px; background: white; transition: transform 0.2s; } .article-item:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); } .article-title { color: #2c3e50; margin-top: 0; border-bottom: 1px solid #eee; padding-bottom: 10px; } .article-content { color: #555; margin-bottom: 15px; } .article-meta { font-size: 0.9em; color: #7f8c8d; text-align: right; } .delete-btn { background: #e74c3c; color: white; border: none; padding: 5px 10px; border-radius: 3px; cursor: pointer; float: right; } .delete-btn:hover { background: #c0392b; } 3. JavaScript (script.js) javascript Copy document.addEventListener('DOMContentLoaded', function() { // Načtení existujících aktualit při načtení stránky loadArticles(); // Přidání nové aktuality document.getElementById('article-form').addEventListener('submit', function(e) { e.preventDefault(); const title = document.getElementById('title').value; const content = document.getElementById('content').value; const date = new Date().toLocaleString('cs-CZ'); if (title && content) { addArticle(title, content, date); document.getElementById('article-form').reset(); } }); }); // Funkce pro načtení aktualit function loadArticles() { const articles = getArticles(); const articlesList = document.getElementById('articles-list'); articlesList.innerHTML = ''; articles.forEach((article, index) => { const articleElement = document.createElement('div'); articleElement.className = 'article-item'; articleElement.innerHTML = `
`; articlesList.appendChild(articleElement); }); } // Funkce pro přidání nové aktuality function addArticle(title, content, date) { const articles = getArticles(); articles.unshift({ title, content, date }); // Přidá na začátek pole localStorage.setItem('articles', JSON.stringify(articles)); loadArticles(); } // Funkce pro smazání aktuality function deleteArticle(index) { const articles = getArticles(); articles.splice(index, 1); localStorage.setItem('articles', JSON.stringify(articles)); loadArticles(); } // Pomocná funkce pro získání aktualit z localStorage function getArticles() { return JSON.parse(localStorage.getItem('articles')) || [ { title: "Mláďata", content: "Neberte mláďata rodičům.", date: new Date().toLocaleString('cs-CZ') }, { title: "Zpravodaj č. 2/2025", content: "Vyšlo druhé vydání Obecního zpravodaje.", date: new Date().toLocaleString('cs-CZ') } ]; } Jak to funguje: Přidávání nových aktualit: Uživatel vyplní formulář a klikne na "Přidat aktualitu" Aktualita se uloží do localStorage a okamžitě zobrazí nahoře v seznamu jde to napsat do jednoho kodu, protože uplne nemam všechny opravnění pro tak velkou upravu webu Ano, zde je kompaktní řešení v jednom HTML souboru, které kombinuje vše potřebné. Tento kód můžete vložit přímo do své stávající stránky (např. jako novou sekci) bez nutnosti vytvářet další soubory: html Copy
Aktuality - Obec Čaková
pondělí 7:30 - 12:00 13:00 - 16:30
středa 7:30 - 12:00 13:00 - 16:30