Skip to content

Commit 690a95e

Browse files
author
Andy Chau
committed
Hero section with background image control
1 parent 903e017 commit 690a95e

File tree

1 file changed

+135
-0
lines changed

1 file changed

+135
-0
lines changed

starter/06-Components/05-hero.html

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
8+
<link
9+
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&family=Rubik:wght@400;500;700&display=swap"
10+
rel="stylesheet"
11+
/>
12+
<title>Omifood Hero Section</title>
13+
<style>
14+
* {
15+
margin: 0;
16+
padding: 0;
17+
box-sizing: border-box;
18+
}
19+
20+
html {
21+
font-family: "Rubik", sans-serif;
22+
color: #444;
23+
}
24+
25+
header {
26+
height: 100vh; /* 100% of view pot height */
27+
position: relative;
28+
color: #fff;
29+
30+
background-image: linear-gradient(
31+
rgba(34, 34, 34, 0.6),
32+
rgba(34, 34, 34, 0.6)
33+
),
34+
url(hero.jpg);
35+
background-size: cover;
36+
/* background-size: contain; */
37+
}
38+
39+
section {
40+
padding: 96px 0;
41+
background-color: #f7f7f7;
42+
}
43+
44+
nav {
45+
font-size: 20px;
46+
font-weight: 700;
47+
padding-top: 36px;
48+
display: flex;
49+
justify-content: space-between;
50+
}
51+
52+
h1 {
53+
font-size: 52px;
54+
margin-bottom: 32px;
55+
line-height: 1.05;
56+
}
57+
58+
h2 {
59+
font-size: 44px;
60+
margin-bottom: 48px;
61+
}
62+
63+
p {
64+
font-size: 20px;
65+
line-height: 1.6;
66+
margin-bottom: 48px;
67+
}
68+
69+
.container {
70+
margin: 0 auto;
71+
width: 1200px;
72+
}
73+
74+
.header-container {
75+
width: 1200px;
76+
position: absolute;
77+
78+
/* In relation to the parent */
79+
left: 50%;
80+
top: 50%;
81+
/* In relation to ELEMENT size */
82+
transform: translate(-50%, -50%);
83+
}
84+
85+
.header-container-inner {
86+
width: 50%;
87+
}
88+
89+
.btn:link,
90+
.btn:visited {
91+
font-size: 24px;
92+
font-weight: 600;
93+
color: #fff;
94+
background-color: #e67e22;
95+
text-decoration: none;
96+
display: inline-block;
97+
padding: 16px 32px;
98+
border-radius: 9px;
99+
}
100+
</style>
101+
</head>
102+
<body>
103+
<header>
104+
<nav class="container">
105+
<div>LOGO</div>
106+
<div>NAVIGATIO</div>
107+
</nav>
108+
<div class="header-container">
109+
<div class="header-container-inner">
110+
<h1>A healty meal delivered to you door, every single day</h1>
111+
<p>
112+
The smart 365-days-per-year food subscription that will amke your
113+
eat healty algin. Tailored to your personla takses and nutritional
114+
needs
115+
</p>
116+
<a href="#" class="btn">Start eating well</a>
117+
</div>
118+
</div>
119+
</header>
120+
<section>
121+
<div class="container">
122+
<h2>Some random heading</h2>
123+
<p>
124+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam
125+
odit illum error est iste! Molestias, quisquam impedit asperiores
126+
eligendi voluptate harum tenetur quasi at minus magnam alias amet
127+
omnis ducimus? Lorem, ipsum dolor sit amet consectetur adipisicing
128+
elit. Odio aperiam nemo ratione quae. Ea, amet. Id repudiandae, nam
129+
repellendus aliquid impedit veniam error, tempore quam harum accusamus
130+
odio sed itaque.
131+
</p>
132+
</div>
133+
</section>
134+
</body>
135+
</html>

0 commit comments

Comments
 (0)