<!DOCTYPE html>
<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Responsive YouTube Thumbnail Downloader</title> <style> /* Base Styles */ body, html { margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f0f2f5; display: flex; justify-content: center; align-items: center; min-height: 100vh; /* Ensure full viewport height */ text-align: center; } .container { padding: 20px; border-radius: 10px; background-color: #ffffff; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); max-width: 90%; /* Max width for smaller devices */ margin: 15px; /* Ensure some margin on smaller screens */ } h1 { color: #333; font-size: 1.5rem; /* Responsive font size */ } .input-group { margin-bottom: 20px; display: flex; flex-wrap: wrap; /* Allow input and button to stack on smaller screens */ justify-content: center; /* Center align for aesthetic appeal */ gap: 10px; /* Space between elements */ } input[type="text"] { flex-grow: 1; /* Allow input to fill available space */ padding: 10px; border: 1px solid #ccc; border-radius: 5px; max-width: 400px; /* Max width to prevent overly wide input on large screens */ } button { padding: 10px 20px; border: none; border-radius: 5px; background-color: #007bff; color: #ffffff; cursor: pointer; white-space: nowrap; /* Prevent button text from wrapping */ } button:hover { background-color: #0056b3; } .thumbnail-section img { max-width: 100%; /* Ensure image is responsive and does not overflow */ border-radius: 5px; margin-top: 20px; } /* Responsive Styles */ @media (max-width: 768px) { h1 { font-size: 1.2rem; /* Smaller font size on smaller devices */ } .input-group { flex-direction: column; /* Stack input and button vertically on smaller screens */ } } </style> </head> <body> <div class="container"> <h1>YouTube Thumbnail Downloader</h1> <div class="input-group"> <input type="text" id="youtubeURL" placeholder="Paste YouTube Video URL here" autofocus> <button onclick="fetchThumbnail()">Download Thumbnail</button> </div> <div id="thumbnailSection" class="thumbnail-section"> <!-- Thumbnail and download button will be injected here --> </div> </div> <script> function fetchThumbnail() { const urlInput = document.getElementById('youtubeURL').value; const videoId = urlInput.split('v=')[1].split('&')[0]; const thumbnailUrl = `https://img.youtube.com/vi/${videoId}/maxresdefault.jpg`; const thumbnailSection = document.getElementById('thumbnailSection'); thumbnailSection.innerHTML = ` <img src="${thumbnailUrl}" alt="YouTube Thumbnail"> <a href="${thumbnailUrl}" target="_blank" download="YouTubeThumbnail.jpg"> <button class="download-btn">Download Original Size</button> </a> `; } </script> </body> </html>