یه همچین چیزی که با زدن رکمه جنریت برامون گوت درست کنه
html <div id="conteaner"> <h1> GENERATE RANDOM QUOTE </h1> <button id="generate">Generate quote</button> <div id="textplace"></div> </div>
css h1{ background-color: #33d30b; box-shadow: inset -1px -3px 3px; border-radius: 4px; } #conteaner{ display: flex; flex-direction: column; align-content: space-around; align-items: center; justify-content: center; } #generate{ background-color: aqua; padding: 17px; font-size:x-large ; border: none; box-shadow: inset -3px -2px 3px; border-radius: 11px; } #textplace{ background-color: #b79898; margin-top: 10px; text-align: center; font-size: 25px; box-shadow: inset -2px -3px 3px; font-size: x-large; display: flex; flex-direction: column; align-items: center; border-radius: 19px; } span{ background-color: #b79898; margin: -28px; padding: 6px; position: absolute; top: 64%; box-shadow: inset -1px -2px 3px; border-radius: 12px; }
js const quotes=[ { id:1, quote:"The greatest glory in living lies not in never falling, but in rising every time we fall.", who:" -Nelson Mandela" }, { id:2, quote:"The way to get started is to quit talking and begin doing.", who:" -Walt Disney"}, {id:3, quote:"The future belongs to those who believe in the beauty of their dreams. ", who:" --Eleanor Roosevelt" },{ id:4, quote: "Spread love everywhere you go. Let no one ever come to you without leaving happier.", who:" -Mother Teresa" }, { id:5, quote:"I never dreamed about success, I worked for it." , who:" -Estee Lauder" }, { id:6, quote:"Success seems to be connected with action. Successful people keep moving. They make mistakes but they don't quit." , who:" -Conrad Hilton" }, { id:7, quote: "There are no secrets to success. It is the result of preparation, hard work, and learning from failure.", who:" -Colin Powell" }, ] const generate=document.getElementById("generate") generate.addEventListener("click",e=>{ const random=Math.floor(Math.random()*7)+1 const textplace=document.getElementById("textplace") textplace.style.padding="79px" const filterbyrandom= quotes.filter((w)=>{ return w.id==random }) filterbyrandom.forEach(e => { const textplace=document.getElementById("textplace") textplace=`"${e.quote}"<br> <span>${e.who}</span>` }); })
لینک دانلود فایل کد ها