Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· openaiHugging Face Suzhen/CodeChat

create a heart beating animation in html css and js and the heart is purple and located…

  1. 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?

  2. 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

  3. 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:

    <div class="heart-wrapper">
      <div class="heart"></div>
    </div>
    

    CSS:

    .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);
      }
    }
    

    JS:

    // No JS needed for this animation
    

    This should produce an animation of a purple heart beating in the center of the screen that works on both phones and PCs.

  4. 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

  5. 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:

    <div id="left"></div>
    <div id="right"></div>
    
    <style>
      body {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-top: 10%;
        animation-name: beat;
        animation-duration: 2s;
        animation-iteration-count: infinite;
      }
    
      #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);
          background-color: purple;
        }
        50% {
          transform: scale(0.8);
          background-color: lightpink;
        }
        100% {
          transform: scale(1.2);
          background-color: rgb(182, 0, 0);
        }
      }
    </style>
    

    In this code, the background-color property is set to purple during the first part of the animation (0% to 50%), then changes to lightpink while the heart is getting smaller, and finally goes back to its original color (rgb(182, 0, 0)) when the heart returns to its original size (50% to 100%).

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.