CMS Development

dzoladz
Participant | Platinum Partner
Participant | Platinum Partner

Display:none not working, looks like visibility:hidden

SOLVE

I have a module that uses the following code.

 

 div id="product_content" (display:block)
     div class="item_conteiner (display:flex) => show
     div class="item_conteiner (display:flex) => show
     div class="item_conteiner (display:flex) => show
     div class="item_conteiner (display:flex) => show
     div class="item_conteiner (display:flex) => display none
     div class="item_conteiner (display:flex) =>display none
     div class="item_conteiner (display:flex) =>display none
     div class="item_conteiner (display:flex) =>display none
/div
Button  id=btnClick => Click to see all Products
 
The script I'm running is;
 
$(document).ready(function () {
     $("#product_content .item_conteiner:nth-of type(n+5)").addClass("hide");
     $("#btnClick").click(function () {
          $("#product_content .item_conteiner:nth-of-type(n+5)").removeClass("hide");
});
});
 
The script works but for some reason the .hide class with css display:none property does not collapse down, so there is existing space where the hidden div's where located.  It looks more like visibility:hidden I rebuit this in VS and it works correctly but not in HubSpot. any advise would be helpful. Thanks.
0 Upvotes
1 Accepted solution
piersg
Solution
Key Advisor

Display:none not working, looks like visibility:hidden

SOLVE

It's because you've given the wrapping #product_content a specific height with inline styling (height: 2199px) and each .item_conteiner is set to absolute positioning (also inline on each element). Remove the height on the parent element and remove the absolute positioning and it should work.

piersg_0-1677516474964.png

 

View solution in original post

0 Upvotes
5 Replies 5
piersg
Key Advisor

Display:none not working, looks like visibility:hidden

SOLVE

Can you give us a link where you're seeing this? It's easier to fix CSS when you can see the actual page 🙂

0 Upvotes
dzoladz
Participant | Platinum Partner
Participant | Platinum Partner

Display:none not working, looks like visibility:hidden

SOLVE

Hello @piersg. Thank you for the assistance. The page I'm referring to is 

https://info.gottmanconnect.com/bundles-just-for-you

Thank you.

0 Upvotes
piersg
Solution
Key Advisor

Display:none not working, looks like visibility:hidden

SOLVE

It's because you've given the wrapping #product_content a specific height with inline styling (height: 2199px) and each .item_conteiner is set to absolute positioning (also inline on each element). Remove the height on the parent element and remove the absolute positioning and it should work.

piersg_0-1677516474964.png

 

0 Upvotes
dzoladz
Participant | Platinum Partner
Participant | Platinum Partner

Display:none not working, looks like visibility:hidden

SOLVE

@piersg Thank you again for the reply.I don't have any inline styling in this custom module so I'm not sure where it's coming from. What should I set the # product_content height to? And what would you suggest I apply to the .item_conteiner position?

 Thank you again.

0 Upvotes
dzoladz
Participant | Platinum Partner
Participant | Platinum Partner

Display:none not working, looks like visibility:hidden

SOLVE

@piersg I figured it out, I had to add height: auto !important; to both parent div's
and add to position: static !important; to the .item_conteiner's. Thanks again for the help!

0 Upvotes