-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path18-CSS Variables (Custom Properties).html
More file actions
58 lines (50 loc) · 1.21 KB
/
18-CSS Variables (Custom Properties).html
File metadata and controls
58 lines (50 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>18 - CSS Variables (Custom Properties)</title>
<style>
/* Reset default browser styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Global CSS Variables */
:root {
--primary-color: #abe622;
--padding: 16px;
}
/* Button styling using global variables */
button {
background-color: var(--primary-color);
padding: var(--padding);
color: white;
border: none;
cursor: pointer;
}
/* Card component with local variables */
.card {
--card-bg: #c92828;
--heading-bg: #c0bd18;
background-color: var(--card-bg);
padding: 20px;
margin-top: 20px;
}
/* Heading uses variable from parent (.card) */
.card1 {
background-color: var(--heading-bg);
padding: 10px;
color: #000;
}
</style>
</head>
<body>
<button>Click me</button>
<div class="card">
Card
<h1 class="card1">Card1</h1>
</div>
</body>
</html>