diff --git a/Day7/eventStyle.css b/Day7/eventStyle.css new file mode 100644 index 0000000..8143f5d --- /dev/null +++ b/Day7/eventStyle.css @@ -0,0 +1,74 @@ +*{ + margin: 0; + padding: 0; + box-sizing: border-box; + font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; +} +body{ + padding: 1rem; + transition: .4s; + display: flex; + flex-direction: column; +} +header{ + display: flex; + justify-content: center; + margin: 30px 0 30px 0; +} +header button{ + padding: 15px; + border-radius: 1rem; + border: none; + background-color: #e9e7ea; + font-size: 15px; + font-weight: bold; + cursor: pointer; +} + +#parent{ + display: flex; + flex-wrap: wrap; +} +h1{ + color: white; + text-align: center; + margin: 10px 0 10px 0; + text-shadow: 0 0 30px black; +} +h4{ + color: #703888; + font-size: 20px; + font-weight: bold; + text-align: center; +} +h6{ + color: #1a5188; + font-size: 18px; + font-weight: bold; + text-align: center; +} +p{ + color: #149054; + font-size: 16px; + font-weight: bold; + text-align: center; +} +.card{ + border-radius: 1rem; + box-shadow: 4px 4px 4px rgb(238, 237, 172); + width: 200px; + background-color: rgb(255, 254, 211); + margin: 1rem auto; + padding: 20px; + transition: .4s; +} +.card:hover{ + box-shadow: 0 0 20px rgb(192, 191, 110); + flex-grow: .3; + cursor: pointer; +} +.card p{ + padding: 10px; + margin: 10px; + transition: .4s; +} \ No newline at end of file diff --git a/Day7/events.js b/Day7/events.js new file mode 100644 index 0000000..3e04cb8 --- /dev/null +++ b/Day7/events.js @@ -0,0 +1,47 @@ +const data = [ + { name: 'Ishanvi', email: 'ishanvi@gmail.com', city: 'Ghaziabad'}, + { name: 'Kshitiz', email: 'kshitiz@gmail.com', city: 'Delhi'}, + { name: 'Asmit', email: 'asmit@gmail.com', city: 'Kanpur'}, + { name: 'Arpit', email: 'arpit@gmail.com', city: 'Jalaun'}, + { name: 'Anisha', email: 'anisha@gmail.com', city: 'Ghaziabad'} +]; + +const root = document.getElementById('parent'); + +data.forEach((elem) => { + const newCard = document.createElement('div'); + newCard.addEventListener("click", () => { + newCard.style.backgroundColor = getRandomColor(); + }); + //setAttribute + //classList.add + newCard.className = 'card'; + newCard.innerHTML = ` +
${elem.city}
+ `; + root.appendChild(newCard); +}) + +const getRandomColor = () => { + const randomRed = Math.floor(Math.random() * 255); + const randomGreen = Math.floor(Math.random() * 255); + const randomBlue = Math.floor(Math.random() * 255); + return `rgb(${randomRed}, ${randomGreen}, ${randomBlue})`; +} + +const body = document.querySelector('body'); +const handleBgChange = () => { + console.log("Button Clicked"); + //Logic to change background color + body.style.backgroundColor = getRandomColor();; +} + +const textElement = document.querySelectorAll('.text'); +textElement.forEach((p) => { + p.addEventListener('click', (event) => { + event.stopPropagation(); + p.style.backgroundColor = getRandomColor(); + },false); +}); \ No newline at end of file diff --git a/Day7/form.html b/Day7/form.html new file mode 100644 index 0000000..4502b8b --- /dev/null +++ b/Day7/form.html @@ -0,0 +1,18 @@ + + + + + +