Gimme some code I can just copy paste somewhere and have it run. I'm on mobile, android…
- User
Gimme some code I can just copy paste somewhere and have it run. I'm on mobile, android specifically. I was thinking a website of sorts.. maybe CSS? Not sure. I want a header that says "Very cool website" and you're welcome to figure out a way to make that stylish. Then I want three numbered panels below, side by side, that I can scroll between. I wanna have it be a smooth scroll, with maybe the center most one being larger, if you get me. Make it pretty, do whatever.
- Assistant
Sure! Here's some code you can copy and paste into a file and open in your mobile browser. It creates a stylish header that says "Very Cool Website" and has three numbered panels below that you can scroll between smoothly. The center panel becomes larger as it comes to the center of the viewport. I've added some styling to make it look pretty.
<!DOCTYPE html> <html> <head> <title>Very Cool Website</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> /* CSS Styles */ body { margin: 0; font-family: Arial, sans-serif; background-color: #222; } header { background: linear-gradient(45deg, #ff6b6b, #556270); padding: 30px; text-align: center; color: white; font-size: 2.5em; box-shadow: 0 2px 5px rgba(0,0,0,0.3); } .container { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scroll-behavior: smooth; padding: 20px 10px; } .panel { flex: 0 0 80%; scroll-snap-align: center; background-color: #f0f0f0; margin: 0 10px; display: flex; justify-content: center; align-items: center; font-size: 4em; height: 300px; border-radius: 20px; flex-shrink: 0; transition: transform 0.3s, background-color 0.3s; box-shadow: 0 2px 10px rgba(0,0,0,0.2); } .panel:nth-child(odd) { background-color: #ff9f9f; } .panel:nth-child(even) { background-color: #9fcfff; } .panel.active { transform: scale(1.2); background-color: #ffe066; } .container::-webkit-scrollbar { display: none; } /* Optional: Styles for small screens */ @media (max-width: 600px) { .panel { flex: 0 0 90%; } } </style> </head> <body> <header> Very Cool Website </header> <div class="container"> <div class="panel">1</div> <div class="panel">2</div> <div class="panel">3</div> </div> <script> // JavaScript for scaling the center panel const container = document.querySelector('.container'); const panels = document.querySelectorAll('.panel'); function updateActivePanel() { let containerRect = container.getBoundingClientRect(); let containerCenterX = containerRect.left + containerRect.width / 2; panels.forEach(panel => { let panelRect = panel.getBoundingClientRect(); let panelCenterX = panelRect.left + panelRect.width / 2; let distance = Math.abs(containerCenterX - panelCenterX); if (distance < panelRect.width / 2) { panel.classList.add('active'); } else { panel.classList.remove('active'); } }); } container.addEventListener('scroll', () => { updateActivePanel(); }); // Initial check to set the active panel on load updateActivePanel(); </script> </body> </html>How to use it:
- Copy the code above.
- On your Android device, open a text editor or code editor app (like "QuickEdit" or "DroidEdit").
- Paste the code into a new file and save it with an
.htmlextension (e.g.,coolwebsite.html). - Use a file manager app to locate the saved HTML file.
- Tap on the file and choose to open it with your web browser (e.g., Chrome).
What it does:
- Stylish Header: Displays a header with a gradient background and custom styling.
- Scrollable Panels: Shows three panels that you can scroll between horizontally.
- Smooth Scroll: Implements smooth scrolling behavior.
- Center Panel Scaling: The panel closest to the center of the viewport scales up slightly to create a focus effect.
- Responsive Design: Adjusts panel widths on smaller screens for a better viewing experience.
Feel free to modify the styles and content to suit your preferences!