This repository contains an HTML and CSS code for creating a simple animation with a moving circle and text. The animation responds to user interactions by changing the size of the circle and updating its position based on the user's mouse movements.
- Overview
- Demo
- Table of Contents
- Features
- Themes
- Prerequisites
- Getting Started
- Usage
- How It Works
- Customization
- Dependencies
- License
You can view a live demo of the animation here.
You have multiple themes to choose from by pressing the right and left arrow keys.
To run this animation, you need a web browser that supports HTML5 and CSS3.
- Clone this repository or download the HTML and CSS files.
- Open the
index.html
file in your preferred web browser.
The animation consists of a circle and text displayed on a black background. The circle responds to user interactions as follows:
- When the mouse hovers over the circle, it increases in size.
- When the mouse leaves the circle, it returns to its original size.
- The position of the circle is updated based on the user's mouse movements.
The animation is achieved using JavaScript and CSS. Here's a breakdown of how it works:
- The HTML structure contains a
div
element with the classcontent
, which represents the main content area. - Inside the
content
element, there is anotherdiv
element with the classesd-flex
,circle
, andtext
. Thecircle
class represents the circle element, and thetext
class represents the text content. - The CSS styles in the
style.css
file define the appearance and behavior of the animation. It sets the initial styles for the circle, text, and overall layout. - In the JavaScript code, a clone of the
content
element is created and assigned to thecontent
variable. This clone is given the classd-absolute
, which positions it absolutely on the page. - The text and background colors for the cloned element are set using CSS custom properties.
- The cloned element is appended to the body of the page, creating a duplicate of the original content element.
- Event listeners are added to the child elements of the original content element. When the mouse hovers over the circle, the size of the cloned element increases. When the mouse leaves the circle, the size of the cloned element returns to its original size.
- An event listener is added to the window to update the position of the cloned element based on the user's mouse movements. The position is calculated relative to the window's dimensions and set using CSS custom properties.
You can customize the appearance of the animation by modifying the CSS styles in the style.css
file. Here are some variables you can adjust:
--text-color
: Change the color of the text.--background-color
: Change the background color.--size
: Adjust the initial size of the circle.
The animation relies on the following external resources:
- Google Fonts: The Poppins font is used for the text.
This project is licensed under the MIT License.
Feel free to explore and modify the code to suit your needs. Enjoy the animation!