Toss the Coin
Press "Toss Coin" to start
Features:
- Toss Coin Animation: The coin flips on clicking the "Toss Coin" button, showing either "Heads" or "Tails" as the result.
- Responsive Design: The layout adjusts to different screen sizes to look good on both mobile and desktop devices.
- Colorful Styling: A gradient background with contrasting colors is used for the coin and button to provide an engaging visual effect.
- Play Again Button: After each toss, the "Play Again" button becomes visible, allowing the user to toss the coin again.
Explanation:
- Coin Flipping: The flipping effect is achieved using CSS transformations (
rotateY()) and transitions, where the coin rotates when tossed. - JavaScript Functionality: The
tossCoinfunction generates a random number to decide whether the result is "Heads" or "Tails", and theresetGamefunction hides the result and resets the button. - UI Elements:
- A coin element (
<div>) is used to display the result (heads or tails). - Toss Coin button triggers the coin flip and displays the result.
- Play Again button lets users reset the game after a toss.
- A coin element (
No comments:
Post a Comment