vendredi 19 février 2021

Style other cards when hover over one CSS

on a part of my site I have a set of 6 cards arranged 3x3 using flexbox, and I want it so when the user hovers over one card, all the others will change background colour or get dimmer (haven't decided yet). Here's an extract of my text, when I hover over a child, it changes all the cards after it, but I would also like it to do the ones before too (so every other card but itself!

Here is my code:

#page3container {
  height: 70%;
  width: 70%;
  background: rgba(25, 25, 25, 0.8);
  position: absolute;
  margin: 0;
  left: 15%;
  top: 22%;
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  flex-wrap: wrap;
  align-items: center;
  border-radius: 15px;
}

.page3card {
  height: 40%;
  width: 30%;
  background: rgb(50, 71, 139);
  border-radius: 15px;
  box-shadow: 0 0 5px rgb(50, 71, 139);
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
}

.card3Title {
  height: 50px;
  margin-top: 2%;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: space-between;
}

.card3Title h3 {
  font-family: 'Play';
  width: 80%;
  color: #d83a3a;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  margin: 0;
  padding-left: 5%;
  height: 50px;
  background: red;
}

.card3Number {
  width: 20%;
}

.card3Text {
  color: white;
  font-family: 'Play';
  padding: 5px;
  text-align: center;
}

.new {
  background: rgb(88, 78, 215);
  overflow: hidden;
  transition: 0.5s;
}

.new:hover {
  box-shadow: 0 0 7px rgb(88, 78, 215);
  transition: 0.5s;
  height: 42%
}

***.new:hover~.new {
  background: red;
}

*** .cardnumber {
  height: 100%;
  width: 45%;
  text-align: left;
  color: rgba(255, 255, 255, 1);
  font-size: 19vw;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
}

.cardcontent {
  height: 100%;
  width: 60%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.cardcontent h1 {
  color: white;
  margin: 0;
  text-align: center;
  height: 40%;
  padding: 0;
  margin-top: 5%;
}

#inner {
  height: 60%;
  width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
}

#inner img {
  width: 8vw;
  height: 8vw;
  margin: 5%;
  margin-bottom: 0;
  object-fit: contain;
}

.cardcontent h1 {
  width: 100%;
  font-size: 2.2vw;
}
<div class="page3card new">
  <div class="cardnumber">1</div>
  <div class="cardcontent">
    <h1 class="cardtitle"><strong>Download Chrome</strong></h1>
    <div id="inner"><img src="img/chrome-icon.webp" id="chrome"></div>

  </div>
</div>
<div class="page3card new">
  <div class="cardnumber">2</div>
  <div class="cardcontent">
    <h1 class="cardtitle"><strong>Create an account</strong></h1>
    <div id="inner"><img src="img/person-icon.png"></div>

  </div>
</div>
<div class="page3card new">
  <div class="cardnumber">3</div>
  <div class="cardcontent">
    <h1 class="cardtitle"><strong>Link Devices</strong></h1>
    <div id="inner"><img src="img/link-icon.png"></div>

  </div>
</div>
<div class="page3card new">
  <div class="cardnumber">4</div>
  <div class="cardcontent">
    <h1 class="cardtitle"><strong>Block websites</strong></h1>
    <div id="inner"><img src="img/stop-icon.svg"></div>

  </div>
</div>
<div class="page3card new">
  <div class="cardnumber">5</div>
  <div class="cardcontent">
    <h1 class="cardtitle"><strong>All set!</strong></h1>
    <div id="inner"><img src="img/check-icon.svg"></div>

  </div>
</div>
<div class="page3card new">
  <div class="cardnumber">6</div>
  <div class="cardcontent">
    <h1 class="cardtitle"><strong>View reports</strong></h1>
    <div id="inner"><img src="img/report-icon.png"></div>

  </div>
</div>
Many thanks!

Thank you :)




Aucun commentaire:

Enregistrer un commentaire