techfortech
techfortech

Reputation: 35

Text disappears on hover CSS

My text disappears when I hover over it. I tried removing the hidden and putting the visibility: visible and I changed the opacity to 1 but I still keep getting the same - the text still disappears when I hover. I am trying to make the text stay the same and do nothing when I hover. The weird thing is I have a box border around it and when I hover the whole lower part disappears with it so half the box and the text disappear too. Am I missing something else?

HTML 
<div class="col-xl-3 col-lg-4 col-md-4 col-sm-6 col-6 ">
   <div class="ps">
       <div class="thumbnail">
           <a href=" "><img src="http://placekitten.com/100/100" alt=" "></a>
            <div class="badge">10%</div>
                  </div>
 <div class="container">
         <a class="v" href="/Animal/Cat">Cat store</a>
 <div class="content">
  <a class="title" href="cat_new">kITTY</a>


 
 </div>
 </div>
  </div>
 </div>

CSS

.title {
    margin: 0;
    display: block;
    padding: 0 0 5px;
    font-size: 14px;
    line-height: 1.2em;
    color: #06c;
    --max-lines: 2;
    max-height: calc(1.2em * var(--max-lines));
    overflow: hidden;
    padding-right: 1rem;
    opacity: 1;}
    
    
    a {
    position: relative;
    color: inherit;
    text-decoration: none;
    transition: all 0.4s ease; }
    
.hover .content {
  visibility: hidden;
  opacity: 1;
  height: 0;
}

.hover {
  border-color: silver;
}

.ps-product--inner .content {
  display: block;
  visibility: visible;
  opacity: 1;
}

Upvotes: 1

Views: 2115

Answers (5)

user15519226
user15519226

Reputation:

please remove the visibility: hidden in "ps-product:hover .ps-product__content" .

 .ps-product__title {
    margin: 0;
    display: block;
    padding: 0 0 5px;
    font-size: 14px;
    line-height: 1.2em;
    color: #06c;
    --max-lines: 2;
    max-height: calc(1.2em * var(--max-lines));
    overflow: hidden;
    padding-right: 1rem;
    opacity: 1;}
    
    
    a {
    position: relative;
    color: inherit;
    text-decoration: none;
    transition: all 0.4s ease; 
 }
    
.ps-product:hover .ps-product__content {
 /*     remove  visibility: hidden;   */
  opacity: 1;
  height: 0;
}

.ps-product:hover {
  border-color: silver;
}

.ps-product:hover.ps-product--inner .ps-product__content {
  display: block;
  visibility: visible;
  opacity: 1;
}

Upvotes: 0

Uttam
Uttam

Reputation: 776

By default it's visibility : visible; which doesn't hide your text while hovering but you had applied this attribute as hidden which results in hiding some content listing inside your ps-product:hover class.

You can either remove the code (visibility: hidden;) or you can change this to visibility: visible; `

Upvotes: 0

Filip Huhta
Filip Huhta

Reputation: 2368

The visibility hidden; makes the element with class ps-product__content disappear when hovering over ps-product. So if you don't want that behavior on your element with class ps-product__content you should remove it like the example below:

.ps-product__title {
    margin: 0;
    display: block;
    padding: 0 0 5px;
    font-size: 14px;
    line-height: 1.2em;
    color: #06c;
    --max-lines: 2;
    max-height: calc(1.2em * var(--max-lines));
    overflow: hidden;
    padding-right: 1rem;
    opacity: 1;}
    
    
    a {
    position: relative;
    color: inherit;
    text-decoration: none;
    transition: all 0.4s ease; }
    
.ps-product:hover .ps-product__content {
 /* 
makes the element with class ps-product__content hidden. 
visibility: hidden; 
*/
  opacity: 1;
  height: 0;
}

.ps-product:hover {
  border-color: silver;
}

.ps-product:hover.ps-product--inner .ps-product__content {
  display: block;
  visibility: visible;
  opacity: 1;
}
<div class="col-xl-3 col-lg-4 col-md-4 col-sm-6 col-6 ">
   <div class="ps-product">
       <div class="ps-product__thumbnail">
           <a href=" "><img src="http://placekitten.com/100/100" alt=" "></a>
            <div class="ps-product__badge">10%</div>
                  </div>
 <div class="ps-product__container">
         <a class="ps-product__vendor" href="/Animal/Cat">Cat store</a>
 <div class="ps-product__content">
  <a class="ps-product__title" href="cat_new">kITTY</a>


 <p class="ps-product__price sale">50000<del>40000</del></p>
 </div>
 </div>
  </div>
 </div>

Upvotes: 0

aphextwix
aphextwix

Reputation: 1858

Remove this rule ...

.ps-product:hover .ps-product__content {
  visibility: hidden;
  opacity: 1;
  height: 0;
}

Upvotes: 0

Tom
Tom

Reputation: 397

Remove the visibility: hidden; and then run the program again, that worked when I tried it.

Upvotes: 1

Related Questions