Raja BWhat does this project do? <html lang="en"> <head> <meta charset="UTF-8"...
What does this project do?
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport"
content="width=device-width,
initial-scale=1.0" />
<title>Random Emojy</title>
<link rel="stylesheet" href="styleEmoji.css" />
</head>
<body>
<div id="emoji">😂</div>
<script src="appEmoji.js"></script>
</body>
</html>
<div id="emoji">😂</div>
This creates one emoji on the webpage.
Page
😂
The id="emoji" is used so JavaScript and CSS can find this element
CSS
body {
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #ccc;
}
#emoji {
font-size: 10rem;
filter: grayscale(1);
cursor: pointer;
transition-property: transform, filter;
transition-duration: 200ms;
}
#emoji:hover {
transform: scale(1.3);
filter: grayscale(0);
}
1.
body
{
height: 100vh;
}
means:
100 = Full height
vh = View Height
So the body occupies the whole browser window
2.
display: flex;
Makes the body a Flexbox container
Without Flexbox
😂
With Flexbox
😂
3.
justify-content: center;
Centers the content vertically
4.
align-items: center;
Centers horizontally
Result:
-------------------------
| |
| |
| 😂 |
| |
| |
-------------------------
5.
font-size: 10rem;
Makes the emoji very large
😂
↓
😂😂😂 (Large size)
6.
filter: grayscale(1);
Makes the emoji appear without color (grayscale)
😀
↓
⚪ Gray-looking emoji
7.
cursor: pointer;
Changes the mouse cursor
Without:
Arrow
With:
☝
It tells the user the element is interactive
8.
transition-duration: 200ms;
Instead of changing instantly,
Small
↓
Large
it changes smoothly
Hover CSS
#emoji:hover
{
transform: scale(1.3);
}
When the mouse is over the emoji,
😂
↓
😆
it becomes 30% larger
scale(1.3) means:
Original = 100%
↓
130%
filter: grayscale(0);
Removes the grayscale effect
Before:
Gray Emoji
After
😀 Full Color