Home > Net >  Why is the second icon's background lagging when i hold on it? how can i solve it?
Why is the second icon's background lagging when i hold on it? how can i solve it?

Time:01-31

I tried to do something like navigation bar in the up of the page i added 2 icons to here and then I wanted to make a shadow when someone hold on it and first icon is working good but the second don't i don't understanding why is it happening.

It has to look like this

But it look like this

HTML code:

.right-selection {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  margin-left: 80px;
}

.basket {
  width: 37px;
  float: left;
  margin-right: 40px;
  display: block;
}

.account {
  float: right;
  width: 25px;
  margin-top: 13px;
  margin-bottom: 12px;
  margin-right: 15px;
}

.basket:hover {
  background-color: rgba(165, 158, 158, 0.5);
  border-radius: 20px;
  border: 2px rgba(165, 158, 158, 0.5);
}

.account:hover {
  background-color: rgba(165, 158, 158, 0.5);
  border-radius: 20px;
  border: 1px rgba(165, 158, 158, 0.5);
}
<div >
  <div >
    <img src="/Images/card.png" alt="basket"  />
  </div>
  <div >
    <img src="/Images/account.png" alt="account"  />
  </div>
</div>

CodePudding user response:

Cleaning up the CSS should help. No need to separate .basket and .account. Give the surrounding div some width & height. Little fiddle here: https://jsfiddle.net/k4nstox5/

.right-selection {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  margin-left: 80px;
}
    
.right-selection div {
  padding: 5px;
  border-radius: 50%;
  width: 24px;
  height: 24px;
}

.right-selection div:hover {
  background-color: rgba(165, 158, 158, 0.5);
  border: 2px rgba(165, 158, 158, 0.5);
}
  • Related