Hello wizards, I hope you are doing great. Today in this blog you’ll learn how to create the "Meme Generator" project using HTML, CSS & JavaScript.
Preview
In the above video, you’ve seen the preview of the "Meme Generator" project and I hope now you are able to create this type of project. If not, I have provided all the HTML CSS and JavaScript code below.
Meme Generator [Source Code]
To get the following HTML, CSS & JS code for the Meme Generator project. You need to create three files one is a HTML file, second one is a CSS file and the another one is JS file. After creating these three files then you can copy-paste the given codes on your document.
Remember, you’ve to create a file with .html extension for HTML code, .css extension for CSS code and .js for JavaScript code.
You can also download all source code files from the given download button.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Meme Generator</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="memeGenerator"> <h1>Meme Generator</h1> <h2 class="title">Title</h2> <img src="" alt="meme" class="meme"> <h4 class="author">Meme Created By Developer </h4> <button class="generateMemeBtn">Generate Meme</button> </div> <script src="index.js"></script> </body> </html>
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&display=swap"); * { margin: 0; padding: 0; box-sizing: border-box; font-family: "Poppins", sans-serif; } body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background-color: yellow; } .memeGenerator { width: 450px; background-color: black; color: white; padding: 20px; border-radius: 10px; display: flex; justify-content: center; align-items: center; flex-direction: column; gap: 15px; } h1 { text-transform: uppercase; font-size: 30px; word-spacing: 3px; margin-bottom: -10px; color: yellow; } .title { font-size: 15px; font-weight: 500; text-align: center; } .meme { height: 200px; object-fit: cover; } .author { font-size: 13px; font-weight: 500; background-color: white; color: black; width: 80%; height: 40px; text-align: center; line-height: 40px; border-radius: 50px; } .generateMemeBtn { font-size: 20px; padding: 20px 40px; font-weight: 500; background-color: yellow; border: none; border-radius: 10px; cursor: pointer; } .generateMemeBtn:active { transform: scale(0.95); }
const titleEl = document.querySelector(".title"); const memeEl = document.querySelector(".meme"); const authorEl = document.querySelector(".author"); const generateMemeBtnEl = document.querySelector(".generateMemeBtn"); // Meme Api GitHub Link : https://github.com/D3vd/Meme_Api async function generateMeme(){ const response = await fetch("https://meme-api.com/gimme/wholesomememes"); const data = await response.json() titleEl.innerHTML = data.title; memeEl.setAttribute("src",data.url); authorEl.innerHTML = `Meme Created By ${data.author}` console.log(data); } generateMemeBtnEl.addEventListener("click",generateMeme) generateMeme();