Code me a web page wich is an online shopping store for puppet toys, only use html, css…
- User
Code me a web page wich is an online shopping store for puppet toys, only use html, css and Javascript
- Assistant
Sure, I can provide you with a simple example of an online shopping store web page for puppet toys using HTML, CSS, and JavaScript. However, please bear in mind that this will be a very basic implementation and might not include advanced features like payment processing or a backend database to store products and orders.
Below is the HTML file with embedded CSS and JavaScript.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Puppet Toys Store</title> <style> body { font-family: Arial, sans-serif; margin: 0; padding: 0; } header { background-color: #f5f5f5; padding: 10px 20px; text-align: center; } h1 { margin: 0; } .products-container { display: flex; flex-wrap: wrap; justify-content: space-around; padding: 20px; } .product-card { border: 1px solid #ddd; border-radius: 4px; padding: 10px; margin: 10px; width: 200px; } .product-card img { max-width: 180px; max-height: 180px; display: block; margin-left: auto; margin-right: auto; } .product-name { font-weight: bold; } .product-price { color: green; } .product-card button { background-color: #4CAF50; color: white; padding: 10px; border: none; border-radius: 4px; cursor: pointer; width: 100%; } .product-card button:hover { background-color: #45a049; } #cart { position: fixed; bottom: 20px; right: 20px; background-color: #f5f5f5; border: 1px solid #ddd; padding: 10px; border-radius: 4px; } #cart span { font-weight: bold; } </style> </head> <body> <header> <h1>Welcome to Puppet Toys Store</h1> </header> <div class="products-container"> <!-- Product 1 --> <div class="product-card" id="product-1"> <img src="puppet1.jpg" alt="Puppet Toy 1"> <div class="product-name">Funny Puppet</div> <div class="product-price">$9.99</div> <button onclick="addToCart(1)">Add to Cart</button> </div> <!-- Product 2 --> <div class="product-card" id="product-2"> <img src="puppet2.jpg" alt="Puppet Toy 2"> <div class="product-name">Cute Puppet</div> <div class="product-price">$12.99</div> <button onclick="addToCart(2)">Add to Cart</button> </div> <!-- Product 3 --> <div class="product-card" id="product-3"> <img src="puppet3.jpg" alt="Puppet Toy 3"> <div class="product-name">Adventure Puppet</div> <div class="product-price">$15.99</div> <button onclick="addToCart(3)">Add to Cart</button> </div> </div> <div id="cart"> Cart: <span id="cart-count">0</span> items </div> <script> let cartCount = 0; function addToCart(productId) { // For simplicity, we will just increment the cart count cartCount++; document.getElementById("cart-count").innerText = cartCount; // In a real-world scenario, you would also want to track the actual products being added to the cart } </script> </body> </html>In this example:
- The web page has a simple header and a list of puppet toys you can purchase.
- Each toy has an "Add to Cart" button that, when clicked, simply increases the number of items in the cart. In a real-world scenario, you'd likely tie this action to a shopping cart system that remembers which items were added, and perhaps a backend system for inventory management.
- The CSS styles written inside the
<style>block are used for a basic layout and styling. - The JavaScript function
addToCart()updates the cart item count when a product's "Add to Cart" button is clicked.
Please note the images for the puppet toys are referenced with
src="puppet1.jpg",src="puppet2.jpg", andsrc="puppet3.jpg", but these images are not provided. You need to have these images available on your server or change thesrcattribute to the correct path where your images are stored.This is a starting point for an online store web page. In a production environment, you'd need to consider additional functionality such as user authentication, inventory management, checkout processes, secure payment handling, and integrating with a backend server to store and retrieve product data and handle orders.