Jump to content

[Share] How to add an Image to Accordion Block

Recommended Posts

You can use this quick tip to add an Image to Accordion Block.

If you can't make it work, you can send image file + send link to page where you use Accordion Block, I will check & give exact code.

#1. Suppose you need to move 2 images to Accordion Item 1 & 3

image.png.9c7a18c0573f9e532569119745ab63ef.png

#2. First, you need to find Accordion Block ID, Image Block ID. Use below tool.

In my example, we will have:

  • Accordion: #block-yui_3_17_2_1_1722935850341_3420
  • Top image: #block-yui_3_17_2_1_1722935850341_3990
  • Bottom Image: #block-979f5f9ef025a462d717

image.png.6619ed676aa30dae7116150fc26da0ef.png

#3. Next, you need to know this.

image.png.17b7ed70c4b8f2fb729c67d7e908d161.png

#4. Use this code to Code Injection > Footer

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
    // move top image
    $('#block-yui_3_17_2_1_1722935850341_3990').appendTo('#block-yui_3_17_2_1_1722935850341_3420 li:nth-child(1) .accordion-item__description');
    // move bottom image
     $('#block-979f5f9ef025a462d717').appendTo('#block-yui_3_17_2_1_1722935850341_3420 li:nth-child(3) .accordion-item__description');
});
</script>
<style>
.accordion-item__description {
    max-width: 100% !important;
}
.accordion-block .image-block {
    margin-top: 10px !important;
}
.accordion-block .image-block .design-layout-fluid * {
    position: relative !important;
    width: 100% !important;
}
.accordion-block .image-block.content-fill img {
    position: static !important;
    object-fit: cover !important;
}
</style>

image.png.c2a33a127a06594c2ac4bbf9c53c0a11.png

#5. Result

image.thumb.png.c94752f148c95910e7687c151230edac.png

image.thumb.png.4c9e127e58b0555c7d8622ef35fda2da.png

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
  • Replies 0
  • Views 680
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

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.