<!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>
<style>
body {
font-family: sans-serif;
margin: 0;
padding: 0;
background-color: #f2f2f2;
}
header {
background-color: #333;
color: #fff;
padding: 1rem 0;
text-align: center;
}
h1 {
margin: 0;
}
nav {
background-color: #ddd;
padding: 1rem 0;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
}
nav li {
margin: 0 1rem;
}
nav a {
text-decoration: none;
color: #333;
}
main {
padding: 2rem;
}
.container {
max-width: 800px;
margin: 0 auto;
background-color: #fff;
padding: 2rem;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.search-bar {
display: flex;
justify-content: center;
margin-bottom: 2rem;
}
.search-bar input {
padding: 0.5rem;
border: 1px solid #ccc;
border-radius: 5px;
width: 300px;
}
.search-bar button {
padding: 0.5rem 1rem;
background-color: #333;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
.book-list {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 2rem;
}
.book-item {
border: 1px solid #ccc;
padding: 1rem;
border-radius: 5px;
}
.book-item img {
width: 100%;
height: 200px;
object-fit: cover;
border-radius: 5px;
}
.book-item h2 {
margin-top: 0.5rem;
}
.book-item p {
margin-bottom: 0.5rem;
}
.book-item .buttons {
display: flex;
justify-content: space-between;
}
.book-item button {
padding: 0.5rem 1rem;
background-color: #333;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<header>
<h1>My Book Library</h1>
</header>
<nav>
<ul>
<li><a href="#">Language</a></li>
<li><a href="#">Genre</a></li>
<li><a href="#">Author</a></li>
</ul>
</nav>
<main>
<div class="container">
<div class="search-bar">
<input type="text" placeholder="Search for books...">
<button>Search</button>
</div>
<div class="book-list">
<div class="book-item">
<img src="https://picsum.photos/200/300" alt="Book Cover">
<h2>Book Title</h2>
<p>Author Name</p>
<div class="buttons">
<button>Read</button>
<button>Download</button>
</div>
</div>
</div>
</div>
</main>
<script>
<!-- dynamically generated PicSum -->
const bookItems = document.querySelectorAll('.book-item');
bookItems.forEach(item => {
const img = item.querySelector('img');
const width = Math.floor(Math.random() * 200) + 100; // Random width 100-300
const height = Math.floor(Math.random() * 100) + 200; // Random height 200-300
img.src = `https://picsum.photos/${width}/${height}`;
});
</script>
</body>
</html>