dotnet-5 Forum

A vibrant community for .NET developers.

Recent Posts

Post 1

Optimizing Legacy Code in .NET

A detailed guide to improving performance in older .NET applications.

Post 2

Best Practices for Dependency Injection

Learn how to structure your .NET code for maintainability and testability.

Post 3

Handling Exceptions in .NET

Essential techniques for robust exception management.

About the Forum

Join discussions, ask questions, and share your .NET knowledge with our community.

Contributions are welcome!

Read More
``` ```css /* style.css */ body { font-family: sans-serif; margin: 0; padding: 0; background-color: #f4f4f4; color: #333; } header { background-color: #2980b9; color: white; padding: 20px; text-align: center; position: sticky; top: 80px; z-index: 100; } header h1 { margin: 0; font-size: 2.5em; } main { padding: 20px; display: flex; flex-wrap: wrap; } .post-grid { width: 40%; padding: 20px; } .post { width: 30%; margin-bottom: 20px; border: 1px solid #ccc; border-radius: 5px; padding: 10px; text-align: center; } .post img { width: 100%; max-width: 300px; height: auto; } .post h3 { margin-bottom: 10px; } .post p { margin-bottom: 5px; } footer { background-color: #2980b9; color: white; padding: 10px; text-align: center; position: sticky; top: 0; } ``` ```javascript // script.js document.addEventListener("DOMContentLoaded", function() { const posts = ["post1.html", "post2.html", "post3.html", "post4.html"]; // Example posts let currentPostIndex = 0; function displayPost(post) { const postDiv = document.createElement("div"); postDiv.classList.add("post"); const img = document.createElement("img"); img.src = post.src; img.alt = post.title; const h3 = document.createElement("h3"); h3.textContent = post.title; const p = document.createElement("p"); p.textContent = post.text; postDiv.appendChild(img); postDiv.appendChild(h3); postDiv.appendChild(p); return postDiv; } // Function to update the page function updatePage() { if (currentPostIndex < posts.length) { const post = posts[currentPostIndex]; const postDiv = displayPost(post); document.body.appendChild(postDiv); currentPostIndex++; } else { // Reset to the first post document.body.appendChild(postDiv); } } // Event listener for the button (example) const button = document.getElementById("showPostButton"); button.addEventListener("click", function() { currentPostIndex = (currentPostIndex + 1) % posts.length; updatePage(); }); }