-
Notifications
You must be signed in to change notification settings - Fork 763
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Virtual Bookshelves</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f5f5f5; | ||
margin: 0; | ||
padding: 0; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
flex-direction: column; | ||
} | ||
|
||
.bookshelf-container { | ||
background-color: #fff; | ||
padding: 20px; | ||
border-radius: 8px; | ||
box-shadow: 0 0 15px rgba(0, 0, 0, 0.1); | ||
width: 500px; | ||
} | ||
|
||
h1 { | ||
color: #333; | ||
text-align: center; | ||
} | ||
|
||
.add-shelf-container, .bookshelves { | ||
margin-top: 20px; | ||
} | ||
|
||
.add-shelf-container input { | ||
padding: 10px; | ||
width: calc(100% - 20px); | ||
border-radius: 5px; | ||
border: 1px solid #ccc; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.add-shelf-container button { | ||
padding: 10px 20px; | ||
background-color: #007BFF; | ||
color: #fff; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
width: 100%; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.add-shelf-container button:hover { | ||
background-color: #0056b3; | ||
} | ||
|
||
.bookshelf { | ||
margin-top: 10px; | ||
padding: 10px; | ||
background-color: #f0f0f0; | ||
border-radius: 5px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.05); | ||
} | ||
|
||
.bookshelf h3 { | ||
margin: 0; | ||
margin-bottom: 10px; | ||
font-size: 18px; | ||
} | ||
|
||
.bookshelf ul { | ||
list-style-type: none; | ||
padding: 0; | ||
} | ||
|
||
.bookshelf ul li { | ||
padding: 5px; | ||
background-color: #e9e9e9; | ||
margin-bottom: 5px; | ||
border-radius: 5px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<div class="bookshelf-container"> | ||
<h1>Virtual Bookshelves</h1> | ||
|
||
<div class="add-shelf-container"> | ||
<input type="text" id="shelfName" placeholder="Enter Bookshelf Name"> | ||
<button onclick="addShelf()">Add Bookshelf</button> | ||
</div> | ||
|
||
<div class="bookshelves" id="bookshelves"> | ||
<!-- Bookshelves will be dynamically added here --> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
function addShelf() { | ||
const shelfName = document.getElementById('shelfName').value; | ||
if (shelfName.trim() === '') { | ||
alert('Please enter a name for the bookshelf.'); | ||
return; | ||
} | ||
|
||
const bookshelfContainer = document.createElement('div'); | ||
bookshelfContainer.className = 'bookshelf'; | ||
|
||
const bookshelfTitle = document.createElement('h3'); | ||
bookshelfTitle.innerText = shelfName; | ||
|
||
const bookList = document.createElement('ul'); | ||
|
||
const addBookButton = document.createElement('button'); | ||
addBookButton.innerText = 'Add Book'; | ||
addBookButton.onclick = function() { | ||
const bookName = prompt('Enter the name of the book:'); | ||
if (bookName && bookName.trim() !== '') { | ||
const bookItem = document.createElement('li'); | ||
bookItem.innerText = bookName; | ||
bookList.appendChild(bookItem); | ||
} else { | ||
alert('Book name cannot be empty.'); | ||
} | ||
}; | ||
|
||
bookshelfContainer.appendChild(bookshelfTitle); | ||
bookshelfContainer.appendChild(bookList); | ||
bookshelfContainer.appendChild(addBookButton); | ||
|
||
document.getElementById('bookshelves').appendChild(bookshelfContainer); | ||
|
||
document.getElementById('shelfName').value = ''; // Clear input field | ||
} | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters