Home > database >  Change background-image for each ::after of the same container
Change background-image for each ::after of the same container

Time:02-04

I don't know how to properly word it but I'm looking for a way to change the background-image for each dot, so each dot has as seperate background image. I can't find a way due to them being connected to the same class and its a ::after so I can't do it within the HTML. I'm looking for 5 different images for the dots on the timeline. I can figure out how to make it a background but I can't make 5 different

.timeline {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
}

.timeline::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  background: seashell;
  left: 50%;
  margin-left: -3px;
}

.container {
  padding: 10px 40px;
  position: relative;
  width: 50%;
}

.container::after {
  content: '';
  position: absolute;
  top: 15px;
  right: -17px;
  width: 25px;
  height: 25px;
  background-image: url("images/coolShibaGif.gif");
  background-size: cover;
  border-radius: 50%;
  z-index: 10;
  border: 4px solid #FC2E20;
  box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
}

.left {
  left: 0;
}

.right {
  left: 50%;
}

.right::after {
  left: -16px;
}

.left::before {
  content: '';
  height: 0px;
  width: 0px;
  position: absolute;
  top: 22px;
  right: 30px;
  border: 10px solid seashell;
  border-width: 10px 0 10px 10px;
  border-color: transparent transparent transparent seashell;
}

.right::before {
  content: '';
  height: 0px;
  width: 0px;
  position: absolute;
  top: 22px;
  left: 30px;
  border: 10px solid seashell;
  border-width: 10px 10px 10px 0;
  border-color: transparent seashell transparent transparent;
}

.content {
  padding: 20px 30px;
  background: seashell;
  border-radius: 6px;
  box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
}


/* Mobile version */

@media screen and (max-width: 600px) {
  .timeline::after {
    left: 31px;
  }
  .container {
    width: 100%;
    padding-left: 70px;
    padding-right: 25px;
  }
  .container::before {
    left: 60px;
    border-width: 10px 10px 10px 0;
    border-color: transparent seashell transparent transparent;
  }
  .left::after,
  .right::after {
    left: 15px;
    z-index: 1;
  }
  .right {
    left: 0;
  }
}
<div >
  <div >
    <div >
      <h2>Phase 0: Just the start -</h2>
      <p>We’ll giveaway 500 whitelist spots to members in our discord community.

      </p>
    </div>
  </div>
  <div >
    <div >
      <h2>Phase 1: Release -</h2>
      <p>Cool Shibas minting will be open on our minting website. We’ll reach out to different influencers to promote our project.</p>
    </div>
  </div>
  <div >
    <div >
      <h2>Phase 2: 25% minted -</h2>
      <p>We'll create a DAO wallet and holders will have a say how much ETH will go into the wallet, We'll put 5 ETH of our own into the wallet. Along with that, we will be doing multiple ETH giveaways for holders and non-holders.</p>
    </div>
  </div>
  <div >
    <div >
      <h2>Phase 3: 50% minted -</h2>
      <p>We'll giveaway 20 Cool Shiba NFTs. Along with that we will also be giving away $25,000 to a charity chosen by the community.</p>
    </div>
  </div>
  <div >
    <div >
      <h2>Phase 4: 100% minted -</h2>
      <p>We will give away a total of $25,000 in giveaways to our holders. We’ll also drop our Cool Shibas merch line to all holders. We’ll also be giving $100,000 to a charity of community’s choice.</p>
    </div>
  </div>
</div>

images.

CodePudding user response:

I think you might be looking for the nth-child selector

.container::after {
    background-image: none; /* Or default fallback image here */
}
.container:nth-child(1)::after {
    background-image: url("images/otherImage.gif");
}
.container:nth-child(2)::after {
    background-image: url("images/otherImage2.gif");
}
.container:nth-child(3)::after {
    background-image: url("images/otherImage3.gif");
}
  •  Tags:  
  • Related