0

I want border on my box, when I hover on button with class .zobacz

This is what I have tried but it does not work.

.product-item ~ .zobacz:hover {
    border:5px solid #000;
}

.product-item{
    border:1px solid #000;
}
<div class="product-item">
 <a href="#" class="title">Platin</a>
 <a href="#" class="title-2">78411/35/30</a>
 <a href="#" class="product-item-image"><img src="images/image-product-list.jpg"></a>
 <span class="price">Cena: </span>
 <span class="price-2">265zł</span>
 <span class="price-3">NETTO</span>
 <div class="clearfix"></div>
 <a href="#" class="zobacz">Zobacz</a>
</div>

Is there any way to get the desired behavior using only CSS & HTML?

Dan Hayden
  • 464
  • 5
  • 17

1 Answers1

2

If you want the border to appear on the parent element (i.e. the container box), you can't do this using CSS seeing as that's a parent (css doesn't have a parent). However, if you just wanted it on the element you hover, you can do:

 .zobacz:hover{}

which will work, adding a border to this element.

.zobacz:hover {
  border: 5px solid #000;
}
.product-item {
  border: 1px solid #000;
}
<div class="product-item">
  <a href="#" class="title">Platin</a>
  <a href="#" class="title-2">78411/35/30</a>
  <a href="#" class="product-item-image">
    <img src="images/image-product-list.jpg">
  </a>
  <span class="price">Cena: </span>
  <span class="price-2">265zł</span>
  <span class="price-3">NETTO</span>
  <div class="clearfix"></div>
  <a href="#" class="zobacz">Zobacz</a>
</div>
Natalie Hedström
  • 2,607
  • 3
  • 25
  • 36
Emz914
  • 131
  • 1
  • 7