Jump to content

Show text block from button trigger?

Recommended Posts

https://aia-24.squarespace.com/art-1-1
PW: notyet

You can see the first image block has a (+) button example, and the following white text blocks are all on top of images of the same size. What I'm hoping to achieve is all image blocks are visible and the text blocks overlaying them are hidden until the (+) button is hovered on, then that images text block appears. it should be the forward most block so that it is on top of the pinned block in the center, and the link in the text box should be clickable. The text block should disappear again when mousing off the image boundary.

I have looked everywhere I can think of to find a plugin that I might be able to adapt to make this work, but no luck.

I'm guessing this would be a code block on top of each image, with the button and caption content inside the code block? I would also like to be able to specify each time if the (+) button is on the bottom left or bottom right. Super extra points if the text box "grows" out of the button as focal point to fill the block parameters!

Can anyone help me code this? 

Edited by dnmddy
Link to comment
  • Replies 4
  • Views 290
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

(1)

Initial: Hide all white text box (eg: Anti•Venom at LMCC, 2020 Collection,..)

Hover image with plus: Show all text box

OR

(2)

Initial: Hide all white text box

Hover image with plus: only displays 1 text box corresponding to the plus image?

If (2), you can use this code to Website > Website Tools > Code Injection > Footer. This code will hide Anti Venom at LMCC text box, and make it appears when hover image with plus.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
  $(document).ready(function(){
  $('div#block-2152ecce8d89d712a2a1').hover(function(){
   $(".fe-block-a2839a16dafe47fe9870").addClass("show");
  }, function(){
   $(".fe-block-a2839a16dafe47fe9870").removeClass("show");
  })
  });
</script>
<style>
.fe-block-a2839a16dafe47fe9870 {
    display: none;
}
  .show {
      display: block !important;
  }
  .show {
      z-index: 999999 !important;
  }
</style>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

thank you @tuanphan I may be able to adapt that code to fit what I'm looking to do, but if you check the page you can see the hover freaks out when I put the button and the text block together (which is what I was trying to describe). I changed the code you gave to use the (+) block as the on hover trigger, and moved the text block up to over that image. 

I'm going to be using to on many images with different text blocks, so I think a code block solution would make more sense instead of calling out a dozen different block IDs in the footer injection?

Could your code be adapted to work in a code block that I can set the size of by dragging the corners to match the image its overlaying, and the code block would show the (+) and then the text overlay on hover? Then I could use this code block over and over on each image with new text each time?

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.