Skip to content

Commit 43c628e

Browse files
author
Joseph Harvey Angeles
committed
Section 3: Implemented BEM
1 parent 0ef8d31 commit 43c628e

File tree

2 files changed

+43
-36
lines changed

2 files changed

+43
-36
lines changed

Natours/starter/css/style.css

+37-30
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,38 @@ Dark green: #28b485
77
88
*/
99

10-
* {
10+
*,
11+
*::before,
12+
*::after {
1113
margin: 0;
1214
padding: 0;
13-
box-sizing: border-box;
15+
box-sizing: inherit;
16+
}
17+
html {
18+
/*font-size: 10px; /* root pixel size, rem reference (1 rem)*/
19+
font-size: 62.5%;
1420
}
15-
1621
body {
1722
font-family: "Lato", sans-serif;
1823
font-weight: 400;
19-
font-size: 16px;
24+
/* font-size: 16px; */
2025
line-height: 1.7;
2126
color: #777;
22-
padding: 10px;
27+
padding: 1rem;
28+
box-sizing: border-box;
2329
}
2430

25-
.logo-box {
31+
.header__logo-box {
2632
position: absolute;
27-
top: 40px;
28-
left: 40px;
33+
top: 4rem;
34+
left: 4rem;
2935
}
3036

31-
.logo {
32-
height: 35px;
37+
.header__logo {
38+
height: 3.5rem;
3339
}
3440

35-
.text-box {
41+
.header__text-box {
3642
position: absolute;
3743
top: 40%;
3844
left: 50%;
@@ -54,35 +60,35 @@ body {
5460
color: #FFF;
5561
text-transform: uppercase;
5662
backface-visibility: hidden; /* hide the background so that when children animates, it doesn't interfere */
57-
margin-bottom: 60px;
63+
margin-bottom: 6rem;
5864
}
5965

60-
.heading-primary-main {
66+
.heading-primary--main {
6167
display: block;
62-
font-size: 60px;
68+
font-size: 6rem;
6369
font-weight: 400;
64-
letter-spacing: 35px;
70+
letter-spacing: 3.5rem;
6571
animation-name: moveInLeft;
6672
animation-duration: 1s;
6773
animation-timing-function: ease-out;
6874
/* animation-iteration-count: 3; */
6975
}
7076

71-
.heading-primary-sub {
77+
.heading-primary--sub {
7278
display: block;
73-
font-size: 20px;
79+
font-size: 2rem;
7480
font-weight: 700;
75-
letter-spacing: 17.4px;
81+
letter-spacing: 1.75rem;
7682
animation: moveInRight 1s ease-out;
7783
}
7884

7985
@keyframes moveInLeft {
8086
0% {
8187
opacity: 0;
82-
transform: translateX(-100px);
88+
transform: translateX(-10rem);
8389
}
8490
80% {
85-
transform: translateX(10px);
91+
transform: translateX(1rem);
8692
}
8793
100% {
8894
opacity: 1;
@@ -93,10 +99,10 @@ body {
9399
@keyframes moveInRight {
94100
0% {
95101
opacity: 0;
96-
transform: translateX(100px);
102+
transform: translateX(10rem);
97103
}
98104
80% {
99-
transform: translateX(-10px);
105+
transform: translateX(-1rem);
100106
}
101107
100% {
102108
opacity: 1;
@@ -107,7 +113,7 @@ body {
107113
@keyframes moveInBottom {
108114
0% {
109115
opacity: 0;
110-
transform: translateY(30px);
116+
transform: translateY(3rem);
111117
}
112118
100% {
113119
opacity: 1;
@@ -118,25 +124,26 @@ body {
118124
.btn:link, .btn:visited {
119125
text-transform: uppercase;
120126
text-decoration: none;
121-
padding: 15px 40px;
127+
padding: 1.5rem 4rem;
122128
display: inline-block;
123-
border-radius: 100px;
129+
border-radius: 10rem;
124130
transition: all .2s;
125131
position: relative;
132+
font-size: 1.6rem;
126133
}
127134

128135
.btn:hover {
129136
transform: translateY(-3px);
130137
/* box-shadow: x-dir y-dir blur color */
131-
box-shadow: 0 10px 20px rgba(0, 0, 0, .2);
138+
box-shadow: 0 1rem 2rem rgba(0, 0, 0, .2);
132139
}
133140

134141
.btn:active { /* clicked state */
135142
transform: translateY(-1px); /* minus 1 to initial state not to hover */
136-
box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
143+
box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .2);
137144
}
138145

139-
.btn-white {
146+
.btn--white {
140147
background-color: #fff;
141148
color: #777;
142149
}
@@ -154,7 +161,7 @@ body {
154161
transition: all .4s;
155162
}
156163

157-
.btn-white::after {
164+
.btn--white::after {
158165
background-color: #fff;
159166
}
160167

@@ -163,7 +170,7 @@ body {
163170
opacity: 0;
164171
}
165172

166-
.btn-animated {
173+
.btn--animated {
167174
animation: moveInBottom .5s ease-out .75s;
168175
animation-fill-mode: backwards; /* apply all initial 0% state of the animation before the animation starts */
169176
}

Natours/starter/index.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
</head>
1515
<body>
1616
<header class="header">
17-
<div class="logo-box">
18-
<img src="img/logo-white.png" alt="Logo" class="logo"/>
17+
<div class="header__logo-box">
18+
<img src="img/logo-white.png" alt="Logo" class="header__logo"/>
1919
</div>
20-
<div class="text-box">
20+
<div class="header__text-box">
2121
<h1 class="heading-primary"> <!-- SEO checks for h1, we want the whole slogan to be the title that's why spans-->
22-
<span class="heading-primary-main">Outdoors</span>
23-
<span class="heading-primary-sub">is where life happens</span>
22+
<span class="heading-primary--main">Outdoors</span>
23+
<span class="heading-primary--sub">is where life happens</span>
2424
</h1>
25-
<a href="#" class="btn btn-white btn-animated">Discover our tours</a>
25+
<a href="#" class="btn btn--white btn--animated">Discover our tours</a>
2626
</div>
2727
</header>
2828

0 commit comments

Comments
 (0)