HTML Explanation
01
The document begins with the standard <!DOCTYPE html> declaration, ensuring proper rendering in browsers.
02
Within the <head>, the character encoding is set to UTF-8, and the viewport is configured for responsiveness.
03
The title, "Bulldog & Bubbles," reflects the theme of the page.
04
In the <body>, an h2 element displays the heading "Lets Go Bulldogs!" in large, vibrant text.
05
Below this, an image of a bulldog (bulldog1) is included, linked via an external source. This image is positioned absolutely and initially centered on the page.
06
A script tag at the bottom of the body adds interactivity, handled by JavaScript.
CSS Explanation
01
The CSS defines the visual styling and layout of the page.
02
A universal selector * resets margin and padding across elements, ensuring consistency.
03
The body is styled as a flex container, centering its content both horizontally and vertically.
04
A linear gradient background transitions from dark blue to transparent, providing a subtle, dynamic backdrop.
05
The h2 element is styled with a large font size and bright yellow color to stand out against the dark background.
06
The bulldog1 class gives the image its initial position at the center of the screen, with a slight scale and rotation for a playful effect.
07
When the user hovers over the page, the bulldog image scales down slightly, adding a sense of depth and movement.
08
The i elements, which are dynamically created by JavaScript, are styled as small circles.
09
These circles mimic bubble-like effects, with a semi-transparent, glowing center and a shadow that gives them a 3D look.
10
The @keyframes animate defines an animation that moves the bubbles from their initial position to a random point on the screen, simulating floating bubbles.
Javascript Explanation
01
JavaScript is used to create dynamic interactivity. An event listener is attached to the mousemove event, tracking the user's cursor movements.
02
When the mouse moves, the position of the bulldog1 image is updated to follow the cursor, creating a fun, engaging effect as the bulldog chases the mouse pointer.
03
Additionally, small bubble-like i elements are created at the cursor's position on each movement.
04
These elements are given random scales and positions to simulate floating bubbles. The getRandomPosition function calculates a random offset for each bubble, adding unpredictability to their motion.
05
Each bubble persists on the screen for a short time before being removed.