create a heart beating animation in html css and js and the heart is purple and located…
- Assistant
I'm sorry, I don't understand what you want me to do. Can you please provide me with more information or a specific request?
- User
create a heart beating animation in html css and js and the heart is purple and located in the middle of the screen works for phones and pc
- Assistant
Sure, here's an example of a heart beating animation in HTML, CSS, and JS that works on both phones and PCs. The heart is purple and located in the middle of the screen:
HTML:
code<div class="heart-wrapper"> <div class="heart"></div> </div>CSS:
code.heart-wrapper { display: flex; justify-content: center; align-items: center; height: 100vh; } .heart { width: 100px; height: 100px; background-color: purple; position: relative; animation: beat-heart 1s infinite ease-in-out; } .heart:before, .heart:after { content: ""; position: absolute; left: 50px; top: 0; background-color: inherit; width: 50px; height: 80px; border-radius: 50px 50px 0 0; transform: rotate(-45deg); transform-origin: 0 100%; } .heart:after { left: 0; transform: rotate(45deg); transform-origin: 100% 100%; } @keyframes beat-heart { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } } - User
#right, #left { width: 200px; height: 200px; background-color: rgb(182, 0, 0); border-top-right-radius: 50%; border-bottom-right-radius: 50%; }
#right { position: relative; left: -50px; transform: rotate(-45deg); }
#right::before { content: ''; width: 200px; height: 200px; background-color: rgb(182, 0, 0); position: absolute; left: -105px; }
#left {
transform: rotate(-135deg); }
#left::before { content: ''; width: 200px; height: 200px; background-color: rgb(182, 0, 0); position: absolute; left: -105px; }
@keyframes beat { 0% { transform: scale(1.2); } 50% { transform: scale(0.8); background-color: lightpink; } 100% { transform: scale(1.2); } }
i have this code for a heart beating animation can you make it when the heart beats it becomes purple and then it comes back to red
- Assistant
Certainly! Here's an updated version of the code that changes the heart color to purple during the animation and back to red when the animation returns to its original size:
code