<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Book Library</title>
<!-- <link rel="stylesheet" href="styles.css"> -->
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
color: #333;
}
header {
background-color: #384d48;
color: white;
padding: 1em 0;
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
}
.header-content {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
max-width: 1200px;
margin: 0 auto;
}
h1 {
margin: 0;
font-size: 2em;
}
.language-select {
margin-right: 2em;
}
.search-bar {
display: flex;
}
.search-bar input {
padding: 0.5em;
font-size: 1em;
border: none;
border-radius: 5px 0 0 5px;
}
.search-bar button {
padding: 0.5em;
font-size: 1em;
border: none;
background-color: #8B8149;
color: white;
border-radius: 0 5px 5px 0;
cursor: pointer;
}
main {
display: flex;
padding: 2em;
}
.categories {
width: 200px;
margin-right: 2em;
}
.categories h2 {
font-size: 1.5em;
margin-bottom: 1em;
}
.categories ul {
list-style: none;
padding: 0;
}
.categories ul li {
margin-bottom: 0.5em;
cursor: pointer;
padding: 0.5em;
border-radius: 5px;
transition: background-color 0.2s;
}
.categories ul li:hover {
background-color: #ddd;
}
.book-gallery {
display: flex;
flex-wrap: wrap;
gap: 2em;
justify-content: center;
flex-grow: 1;
}
.book {
background-color: white;
border: 1px solid #ddd;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
overflow: hidden;
width: 200px;
text-align: center;
transition: transform 0.2s;
}
.book img {
width: 100%;
height: auto;
}
.book h2 {
font-size: 1.2em;
margin: 0.5em 0;
}
.book p {
font-size: 1em;
color: #555;
margin: 0.5em 0;
}
.book-options {
display: flex;
justify-content: space-around;
margin-bottom: 1em;
}
.book-options button {
padding: 0.5em 1em;
font-size: 1em;
border: none;
border-radius: 5px;
cursor: pointer;
background-color: #ACAD94;
color: white;
}
.book-options button:hover {
background-color: #8B8149;
}
.book:hover {
transform: scale(1.05);
}
</style>
</head>
<body>
<header>
<div class="header-content">
<h1>Book Library</h1>
<div class="language-select">
<label for="language">Language:</label>
<select id="language" name="language">
<option value="en">English</option>
<option value="ar">Arabic</option>
<!-- Add more languages as needed -->
</select>
</div>
<div class="search-bar">
<input type="text" id="search" placeholder="Search for books...">
<button onclick="searchBooks()">Search</button>
</div>
</div>
</header>
<main>
<aside class="categories">
<h2>Categories</h2>
<ul id="category-list">
<li onclick="filterByCategory('all')">All</li>
<li onclick="filterByCategory('fiction')">Fiction</li>
<li onclick="filterByCategory('non-fiction')">Non-Fiction</li>
<li onclick="filterByCategory('science')">Science</li>
<li onclick="filterByCategory('history')">History</li>
<!-- Add more categories as needed -->
</ul>
</aside>
<section class="book-gallery">
<!-- Example book item -->
<div class="book" data-category="fiction">
<img src="https://picsum.photos/200/300" alt="Book 1">
<h2>Book Title 1</h2>
<p>Author 1</p>
<div class="book-options">
<button onclick="readBook('book1.pdf')">Read</button>
<button onclick="downloadBook('book1.pdf')">Download</button>
</div>
</div>
<div class="book" data-category="fiction">
<img src="https://picsum.photos/200/300" alt="Book 1">
<h2>Book Title 1</h2>
<p>Author 1</p>
<div class="book-options">
<button onclick="readBook('book1.pdf')">Read</button>
<button onclick="downloadBook('book1.pdf')">Download</button>
</div>
</div>
<div class="book" data-category="fiction">
<img src="https://picsum.photos/200/300" alt="Book 1">
<h2>Book Title 1</h2>
<p>Author 1</p>
<div class="book-options">
<button onclick="readBook('book1.pdf')">Read</button>
<button onclick="downloadBook('book1.pdf')">Download</button>
</div>
</div>
<div class="book" data-category="fiction">
<img src="https://picsum.photos/200/300" alt="Book 1">
<h2>Book Title 1</h2>
<p>Author 1</p>
<div class="book-options">
<button onclick="readBook('book1.pdf')">Read</button>
<button onclick="downloadBook('book1.pdf')">Download</button>
</div>
</div>
<!-- Add more book items with appropriate data-category attributes -->
</section>
</main>
<script >
function searchBooks() {
let query = document.getElementById('search').value.toLowerCase();
let books = document.querySelectorAll('.book');
books.forEach(book => {
let title = book.querySelector('h2').textContent.toLowerCase();
if (title.includes(query)) {
book.style.display = 'block';
} else {
book.style.display = 'none';
}
});
}
function readBook(file) {
window.open(file, '_blank');
}
function downloadBook(file) {
let link = document.createElement('a');
link.href = file;
link.download = file;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
function filterByCategory(category) {
let books = document.querySelectorAll('.book');
books.forEach(book => {
if (category === 'all' || book.getAttribute('data-category') === category) {
book.style.display = 'block';
} else {
book.style.display = 'none';
}
});
}
</script>
</body>
</html>