A simple, interactive web application that displays the 26 letters of the alphabet in a grid. Hovering over a letter shows a small example image above it (e.g., an apple for 'A'), and clicking a letter opens a visually appealing modal centered on the screen, displaying the letter, an example word, and an enlarged image.
- Alphabet Grid: Displays all 26 letters (A-Z) in a responsive grid layout (6 columns on desktop, 3 on mobile).
- Hover Effect: On hover, a small image of an example word (e.g., 'Apple' for 'A') appears above the letter.
- Click Modal: Clicking a letter opens a centered modal with the letter, example word, and an enlarged image.
- Visually Appealing Modal:
- Gradient background, rounded corners, and subtle shadows.
- Smooth fade-in and scale animations.
- Semi-transparent overlay with a blur effect (supported in modern browsers).
- Stylish close button with hover animation (rotates and changes color).
- Responsive Design: Adapts to different screen sizes, with adjusted font sizes, image dimensions, and grid layout.
- Accessibility: Includes
altattributes for images and supports closing the modal with the Escape key. - Multiple Close Options: Close the modal via:
- The close button.
- Clicking outside the modal content.
- Pressing the Escape key.
- HTML: Structure for the alphabet grid and modal.
- CSS: Styling with CSS Grid, Flexbox, animations, and media queries for responsiveness.
- JavaScript: Dynamic creation of letter boxes and modal functionality.
- Google Fonts: Uses the 'Poppins' font for a modern look (falls back to Arial if unavailable).
- A modern web browser (e.g., Chrome, Firefox, Edge, Safari).
- A local server (optional, recommended for testing, e.g.,
live-servervia npm). - Images for each letter (named
a.jpgtoz.jpg) or placeholder URLs.
-
Clone or Download the Repository:
git clone <repository-url> cd alphabet-hover-example
Alternatively, download and extract the project files.
-
Project Structure:
alphabet-hover-example/ ├── images/ │ ├── a.jpg │ ├── b.jpg │ └── ... (images for c.jpg to z.jpg) ├── index.html ├── styles.css ├── script.js └── README.md -
Add Images:
- Place 26 images (named
a.jpgtoz.jpg) in theimagesfolder, each corresponding to an example word (e.g.,a.jpgfor 'Apple'). - Alternatively, edit
script.jsto use placeholder URLs, e.g.:A: { word: 'Apple', image: 'https://via.placeholder.com/150?text=A' },
- Place 26 images (named
-
Run the Project:
- Option 1: Open
index.htmldirectly in a browser (drag and drop or double-click). - Option 2 (Recommended): Serve the project using a local server to avoid CORS issues with images:
This opens the project at
npm install -g live-server live-server
http://localhost:8080.
- Option 1: Open
-
View the Alphabet Grid:
- The homepage displays a grid of 26 letters (A-Z).
-
Hover Over a Letter:
- Hover over any letter to see a small image of an example word (e.g., an apple for 'A') appear above the letter.
-
Click a Letter:
- Click a letter to open a modal centered on the screen, showing the letter, example word, and an enlarged image.
-
Close the Modal:
- Click the close button (circular '×' in the top-right corner).
- Click outside the modal content.
- Press the Escape key.
-
Responsive Testing:
- Resize the browser or use a mobile device to test the responsive layout (grid switches to 3 columns on screens < 600px).
-
Images:
- Replace
images/a.jpgtoimages/z.jpgwith your own images. - Update the
examplesobject inscript.jsto change example words or use different image URLs:A: { word: 'Ant', image: 'images/ant.jpg' },
- Replace
-
Modal Styling:
- Modify the gradient in
.modal-content(instyles.css):background: linear-gradient(135deg, #e0e7ff, #c3d7ff);
- Adjust the modal size by changing
max-widthin.modal-content. - Change the close button's hover color (
background-colorin.close-button:hover).
- Modify the gradient in
-
Hover Image Position:
- Adjust
bottom: 110pxin.example-imageto change how far above the letter the hover image appears.
- Adjust
-
Animations:
- Modify the modal's fade-in (opacity) or scale animation timings in
.modaland.modal-content. Example: Changetransition: transform 0.3stotransition: transform 0.5sfor a slower animation.
- Modify the modal's fade-in (opacity) or scale animation timings in
-
Fonts:
- Replace 'Poppins' by updating the Google Fonts link in
index.htmlor removing it to use the Arial fallback.
- Replace 'Poppins' by updating the Google Fonts link in
- Hover over 'A' to see an apple image above the letter.
- Click 'A' to open a modal centered on the screen, showing 'A', 'Apple', and a larger apple image.
- Close the modal by clicking the red rotating '×', clicking outside, or pressing Escape.
- Image Paths: Ensure images are correctly placed in the
imagesfolder or updatescript.jswith valid URLs. Placeholder URLs (e.g.,https://via.placeholder.com/150?text=A) work for testing. - Browser Compatibility:
- The
backdrop-filter: blur(5px)in the modal is supported in modern browsers (Chrome, Edge, Safari, Firefox with flags). Older browsers fall back to a solid overlay.
- The
- Performance:
- Optimize images (e.g., use WebP format or compress JPGs) to improve load times, especially for the modal.
- Accessibility:
- Images include
altattributes for screen readers. - The modal supports keyboard navigation (Escape key to close).
- For enhanced accessibility, consider adding:
<div class="modal" id="imageModal" role="dialog" aria-labelledby="modalLetter">
- Images include
- Edge Cases:
- If images fail to load, check file paths or network connectivity.
- On very small screens, the modal image is capped at
max-height: 200pxto prevent overflow.
Feel free to fork this repository, make improvements, and submit pull requests. Suggestions for new features (e.g., sound effects, additional animations) or bug fixes are welcome.
This project is open-source and available under the MIT License. Feel free to use, modify, and distribute it as needed.
For questions or support, contact the project maintainer or open an issue in the repository.also you can contact me.
-
Images: The README assumes images are in an
imagesfolder. If you're using placeholder URLs, update theexamplesobject inscript.jsand mention this in the README's setup section. -
Repository: If you're hosting this on GitHub or another platform, replace
<repository-url>with the actual URL. -
License: I referenced an MIT License; create a LICENSE file in your project if you want to include one, or update the README to reflect your licensing choice.
-
Local Testing: The
live-serversuggestion ensures images load correctly. If you prefer another method (e.g., Python'shttp.server), I can update the instructions. -
Customization: If you want specific additions to the README (e.g., screenshots, a demo link, or more detailed customization), let me know!