Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9926f6e

Browse files
committed
Project #16 - Build Responsive Animated Simple Website With Light And Dark Theme
1 parent2c4d684 commit9926f6e

File tree

6 files changed

+314
-0
lines changed

6 files changed

+314
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<!DOCTYPE html>
2+
<htmllang="en">
3+
<head>
4+
<metacharset="UTF-8"/>
5+
<metaname="viewport"content="width=device-width, initial-scale=1.0"/>
6+
<link
7+
rel="stylesheet"
8+
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"
9+
integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA=="
10+
crossorigin="anonymous"
11+
/>
12+
<linkrel="stylesheet"href="style.css"/>
13+
<title>Landing Page</title>
14+
</head>
15+
<body>
16+
<!--
17+
Tutorial Link: https://youtu.be/BrhiNxiIN3U
18+
19+
Kindly Like, Subscribe & Share.
20+
21+
-->
22+
<header>
23+
<divclass="wrapper header-wrapper">
24+
<nav>
25+
<ahref="#"class="logo">LOGO</a>
26+
<ulclass="navbar">
27+
<li><ahref="#"class="navbar__link">Products</a></li>
28+
<li><ahref="#"class="navbar__link">Iphone 12</a></li>
29+
</ul>
30+
</nav>
31+
<labelfor="theme-checkbox"class="theme-toggler">
32+
<inputtype="checkbox"id="theme-checkbox"class="theme-checkbox"/>
33+
<divclass="switch"></div>
34+
</label>
35+
</div>
36+
</header>
37+
<main>
38+
<divclass="wrapper">
39+
<sectionclass="hero">
40+
<divclass="hero__intro">
41+
<h1>Buy Iphone 12</h1>
42+
<p>
43+
<ahref="https://youtu.be/BrhiNxiIN3U">Tutorial Link</a> dolor sit
44+
amet consectetur adipisicing elit. Maiores voluptas voluptates
45+
tenetur ad officiis ea corporis quos voluptatibus vitae illo
46+
corrupti quas, libero eaque sint soluta, eos natus, similique
47+
asperiores.
48+
</p>
49+
<buttonclass="btn btn-cta">
50+
<iclass="fas fa-shopping-cart"></i> Add To Cart
51+
</button>
52+
</div>
53+
<divclass="hero__photo">
54+
<imgsrc="./imgs/iphone.png"alt=""/>
55+
</div>
56+
</section>
57+
</div>
58+
</main>
59+
60+
<scriptsrc="main.js"defer></script>
61+
</body>
62+
</html>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
consttheme_checkbox=document.getElementById("theme-checkbox");
2+
3+
consttheme=localStorage.getItem("theme");
4+
5+
if(theme){
6+
document.documentElement.setAttribute("data-theme","dark");
7+
if(theme==="dark"){
8+
theme_checkbox.checked=true;
9+
}
10+
}
11+
12+
theme_checkbox.addEventListener("change",function(){
13+
if(this.checked){
14+
document.documentElement.setAttribute("data-theme","dark");
15+
localStorage.setItem("theme","dark");
16+
}else{
17+
document.documentElement.removeAttribute("data-theme");
18+
localStorage.removeItem("theme");
19+
}
20+
});
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
:root {
2+
--nav-height:60px;
3+
}
4+
5+
*,
6+
*::before,
7+
*::after {
8+
box-sizing: border-box;
9+
}
10+
11+
html {
12+
font-family:"Poppins","Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
13+
--primary-color:#0099ff;
14+
--color-body:#f3f3f3;
15+
--color-text:#383636;
16+
--btn-cta-shadow:rgba(0,0,0,0.1);
17+
}
18+
19+
html[data-theme="dark"] {
20+
--primary-color:#2c2c2c;
21+
--color-body:#494242;
22+
--color-text:#f3f3f3;
23+
--btn-cta-shadow:rgba(255,255,255,0.1);
24+
}
25+
26+
html[data-theme="dark"]* {
27+
transition: all0.3s ease;
28+
}
29+
30+
body {
31+
margin:0;
32+
background-color:var(--color-body);
33+
line-height:2;
34+
}
35+
36+
/* global */
37+
a {
38+
text-decoration: none;
39+
}
40+
41+
p,
42+
h1 {
43+
color:var(--color-text);
44+
}
45+
46+
ul {
47+
margin:0;
48+
padding:0;
49+
list-style-type: none;
50+
}
51+
52+
.wrapper {
53+
/* clamp(min, prefered, max) */
54+
width:clamp(320px,95%,1200px);
55+
margin:0 auto;
56+
}
57+
58+
.btn {
59+
padding:0.5rem1rem;
60+
outline: none;
61+
border: none;
62+
}
63+
64+
/* navbar */
65+
header {
66+
height:var(--nav-height);
67+
background-color:var(--primary-color);
68+
}
69+
70+
.header-wrapper {
71+
display: flex;
72+
justify-content: space-between;
73+
align-items: center;
74+
height:100%;
75+
}
76+
77+
nav {
78+
display: flex;
79+
align-items: center;
80+
}
81+
82+
.logo {
83+
font-size:1.5rem;
84+
font-weight:500;
85+
color:#f3f3f3;
86+
}
87+
88+
.navbar {
89+
display: flex;
90+
}
91+
92+
.navbar__link {
93+
color:#f3f3f3;
94+
padding:01rem;
95+
}
96+
97+
/* switch */
98+
.theme-checkbox {
99+
display: none;
100+
}
101+
102+
.switch {
103+
display: flex;
104+
align-items: center;
105+
position: relative;
106+
width:55px;
107+
height:30px;
108+
background-color:#f3f3f3;
109+
border-radius:3rem;
110+
}
111+
112+
.switch::before {
113+
position: absolute;
114+
content:"";
115+
left:2px;
116+
height:26px;
117+
width:26px;
118+
border-radius:50%;
119+
transform:scale(1.3);
120+
transition: left0.3s ease-in;
121+
box-shadow:0px2px1px-1pxrgba(0,0,0,0.2),
122+
0px1px1px0pxrgba(0,0,0,0.14),0px1px3px0pxrgba(0,0,0,0.12);
123+
background:#fffurl("./imgs/sun.png");
124+
background-size:18px;
125+
background-repeat: no-repeat;
126+
background-position: center;
127+
}
128+
129+
.theme-checkbox:checked+ .switch {
130+
background-color:rgb(218,216,216);
131+
}
132+
133+
.theme-checkbox:checked+ .switch::before {
134+
left:25px;
135+
background:#fffurl("./imgs/moon.png");
136+
background-size:18px;
137+
background-repeat: no-repeat;
138+
background-position: center;
139+
}
140+
141+
/* hero */
142+
.hero {
143+
display: flex;
144+
justify-content: center;
145+
align-items: center;
146+
height:calc(100vh-var(--nav-height));
147+
}
148+
149+
.hero .hero__intro {
150+
flex:1;
151+
animation: animateLeft1s ease;
152+
}
153+
.hero .hero__introh1 {
154+
font-size:4.5rem;
155+
font-weight:600;
156+
margin:0.5rem0;
157+
}
158+
.btn-cta {
159+
padding:1rem2rem;
160+
font-size:1.5rem;
161+
background-color:var(--primary-color);
162+
color:#f3f3f3;
163+
border-radius:3rem;
164+
}
165+
166+
.btn-cta:hover {
167+
box-shadow:0006pxvar(--btn-cta-shadow);
168+
}
169+
170+
.btn-cta:active {
171+
transform:scale(0.98);
172+
}
173+
174+
.hero .hero__photo {
175+
flex:1;
176+
display: flex;
177+
justify-content: flex-end;
178+
animation: animateRight1s ease;
179+
}
180+
181+
@keyframes animateLeft {
182+
from {
183+
opacity:0.2;
184+
transform:translateX(-150px);
185+
}
186+
to {
187+
opacity:1;
188+
transform:translateX(0);
189+
}
190+
}
191+
@keyframes animateRight {
192+
from {
193+
opacity:0.2;
194+
transform:translateX(150px);
195+
}
196+
to {
197+
opacity:1;
198+
transform:translateX(0);
199+
}
200+
}
201+
202+
.hero .hero__photoimg {
203+
height:60vh;
204+
}
205+
206+
@media screenand (max-width:768px) {
207+
.header-wrapper {
208+
padding:01rem;
209+
}
210+
211+
.hero {
212+
flex-direction: column-reverse;
213+
text-align: center;
214+
}
215+
216+
.hero .hero__photo {
217+
display: flex;
218+
align-items: center;
219+
}
220+
221+
.hero .hero__intro {
222+
padding:1rem2rem;
223+
}
224+
225+
.hero .hero__introh1 {
226+
font-size:3rem;
227+
}
228+
229+
.hero .hero__photoimg {
230+
height:30vh;
231+
}
232+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp