html
html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
<title>Book Shop</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css">
<link rel="stylesheet" href="./css/style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.css" />
</head>
<body>
<!--Header section starts-->
<header class="header">
<div class="header-1">
<a href="#" class="logo"><i class="fas fa-book"></i>Bo<span>ok.io</span></a>
<form action="" class="search-form">
<input type="search" name="" placeholder="Search here..." id="search-box">
<label for="search-box" class="fas fa-search"></label>
</form>
<div class="icons">
<div id="search-btn" class="fas fa-search"></div>
<a href="#" class="fas fa-heart"></a>
<a href="#" class="fas fa-shopping-cart"></a>
<div id="login-btn" class="fas fa-user"></div>
</div>
Enter to Rename, Shift+Enter to Preview
css
css
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
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300&family=Roboto:ital,wght@0,700;1,100&display=swap');
* {
font-family: 'Poppins', sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
outline: none;
border: none;
text-decoration: none;
text-transform: capitalize;
transition: all .2s linear;
transition: width none;
}
:root {
--gray: rgb(197, 197, 196);
--dark-color: rgba(139, 139, 138, 0.786);
--black: #444;
--light-color: #666;
--box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .1);
}
.heading {
text-align: center;
margin-bottom: 2rem;
position: relative;
}
Enter to Rename, Shift+Enter to Preview
js
js
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
const searchform = document.querySelector('.search-form');
document.querySelector('#search-btn').onclick = () => {
searchform.classList.toggle('active');
}
const userlogin = document.querySelector('.login-form-container');
document.querySelector('#login-btn ').onclick = () => {
userlogin.classList.toggle('active');
}
const closeLogin = document.querySelector('.login-form-container');
document.querySelector('#close-login-btn').onclick = () => {
closeLogin.classList.remove('active');
}
window.onscroll = () => {
searchform.classList.remove('active');
if (window.scrollY > 80) {
document.querySelector('.header .header-2').classList.add('active');
} else {
document.querySelector('.header .header-2').classList.remove('active')
}
}
window.onload = () => {
closeLogin.classList.remove('active');
searchform.classList.remove('active');
if (window.scrollY > 80) {
document.querySelector('.header .header-2').classList.add('active');
} else {
document.querySelector('.header .header-2').classList.remove('active')
}
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run