Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Adding dropdown/accordion with images inside


jamesmabrown

Question

Hello,

I'm trying to add an accordion/dropdown to a website (it's still in trial at the moment so can't share web link). It is going to be used on a page showing the team of a company, so within each entry it also needs to include a picture of them.

I have used the standard markdown used for an accordion, which by itself (without an image in it) works fine. I have then used an HTML image reference within it, and when it does this, only the first name appears. And when it is opened/clicked, the next name then appears below it (and so forth). But then when you close the top name, they all disappear (apart from the top one).

I have also tried created an animated collapsible using HTML, CSS and Java (https://www.w3schools.com/howto/howto_js_collapsible.asp). This code was copied exactly, using a code block for the HTML, adding the CSS into the custom CSS, and adding the Javascript into the page specific code injection. The list options are created, but don't actually open when clicked on. 

If anyone can provide any insight into how to get either of these solutions to work that would be greatly appreciated. Screenshots are attached for reference.

To confirm, I'm using the Henson template.

Many thanks,

James

Screenshot 2021-01-08 at 11.49.33.png

Screenshot 2021-01-08 at 11.49.39.png

Screenshot 2021-01-08 at 11.50.04.png

Screenshot 2021-01-08 at 11.50.08.png

Screenshot 2021-01-08 at 11.50.58.png

Screenshot 2021-01-08 at 11.51.11.png

Screenshot 2021-01-08 at 11.52.16.png

Link to comment

25 answers to this question

Recommended Posts

  • 0

Just an update, this has now been resolved. For anyone that wants to do something similar in the future, the full code is here.

HTML here
<div class="row">
  <div class="col">
    <h1>Heading here</b></h1>
    <div class="tabs">
      <div class="tab">
        <input type="checkbox" id="chck1">
        <label class="tab-label" for="chck1">
			<h2>Title here.
			</h2>
		</label>
        <div class="tab-content">
          <div class="container">
            
        
		<img src="URL" class="container__image"> <div class="container__text">
            <p>
Some internal content here.
            </p>

            </div>
  </div>

        </div>
      </div>
      <div class="tab">
        <input type="checkbox" id="chck2">
        <label class="tab-label" for="chck2"><h2>
          
          A title here</h2></label>
        <div class="tab-content">
          <div class="container">
            
        
		<img src="URL" class="container__image"> <div class="container__text">
            <p>
Some internal content here.
            </p>

            </div>
  </div>
        </div>
      </div>
      
      
/*CSS here*/
      
      // General

input {
  position: ;
  opacity: 0;
  z-index: -1;
}
// Layout
.row {
  display:flex;
  .col {
    flex:1;
    &:last-child {
      margin-left: 1em;
    }
  }
}
/* Accordion styles */
.tabs {
  border-radius: 0px;
  overflow: hidden;
}
.tab {
  width: 100%;
  color: ;
  overflow: hidden;
  &-label {
    display: flex;
    padding: 1em;
    background: ;
    justify-content: space-between;
    font-weight: bold;
    border-bottom: 1px solid #f7b8a1; 
  	padding-bottom:20px;
    cursor: pointer;
/* Icon */
    &:hover {
      background: ;
    }
    &::after {
      content: "\276F";
      width: 1em;
      height: 1em;
      text-align: center;
      transition: all .35s;
    }
  }
  &-content {
    max-height: 0;
    padding: 0 0em;
    color: ;
    background: ;
    transition: all .35s;
  }
  &-close {
    display: flex;
    justify-content: flex-end;
    padding: 1em;
    font-size: 0.75em;
    background: ;
    cursor: pointer;
    &:hover {
      background: ;
    }
  }
}

// :checked
input:checked {
  + .tab-label {
    background: ;
    &::after {
      transform: rotate(90deg);
    }
  }
  ~ .tab-content {
    max-height: 150vh;
    padding-top: 10px;
}
  }
      
      .container {
  &__image {
    display: inline-block;
    vertical-align: top;
    width: 25%;
    margin-right: 25px;
    position: relative;
    min-width: 200px;
    margin-bottom: 20px;
  }
  &__text {
    display: inline-block;
    width: 60%;
    font-size: 1.3em;
    overflow: visible;
    @media (max-width: 1000px) {
      width: 100%;
    }
  }
}

 

Link to comment
  • 0

Hi. If you can share site url, we can check easier.

If your site is private/trial, you can setup password & share url.

If you can't share url, you can consider using this Accordion Plugin. It has more options & easy to install.

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 0

Hi @tuanphan,

There is a link to the site here: https://nectarine-tuba-pgnf.squarespace.com/contact-us-3
PW: PeoplePlacePurpose

I have managed to find a solution to it, using HTML and CSS, but have now run in to the issue that it does not scale properly for mobile (i.e. the content cuts off and cannot be scrolled), and I also can't align the IMG within the content without it affecting the rest of the dropdown. Ideally I'd have the image fixed left (or right) with the text flowing next to it. As a reference, I want to try and get this (https://nectarine-tuba-pgnf.squarespace.com/contact-us-5-grid-2) but collapsible. 

If you can provide any advice it would be greatly appreciated.

All best,

James

Edited by jamesmabrown
providing reference
Link to comment
  • 0
20 hours ago, jamesmabrown said:

Hi @tuanphan,

There is a link to the site here: https://nectarine-tuba-pgnf.squarespace.com/contact-us-3
PW: PeoplePlacePurpose

I have managed to find a solution to it, using HTML and CSS, but have now run in to the issue that it does not scale properly for mobile (i.e. the content cuts off and cannot be scrolled), and I also can't align the IMG within the content without it affecting the rest of the dropdown. Ideally I'd have the image fixed left (or right) with the text flowing next to it. As a reference, I want to try and get this (https://nectarine-tuba-pgnf.squarespace.com/contact-us-5-grid-2) but collapsible. 

If you can provide any advice it would be greatly appreciated.

All best,

James

Hi,

Which code did you use? Can you post here? We will try tweaking it.

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 0

Hi @tuanphan,

The HTML is here:

<div class="row">
  <div class="col">
    <h1>OUR TEAM</b></h1>
    <div class="tabs">
      <div class="tab">
        <input type="checkbox" id="chck1">
        <label class="tab-label" for="chck1">
			<h2>Thomas Rose, Co-Founder
			</h2>
		</label>
        <div class="tab-content">
			           <img src="https://i.ibb.co/ZXt6CVT/Screenshot-2021-01-07-at-17-14-58.png" align=”left” style=”margin: 0px 10px 0px 0px;” width="300px">
          Thomas Co-founded P-THREE in 2019 after working as head of Leisure & Restaurants at Cushman & Wakefield for 13 years.<br>

Thomas has worked on projects across the UK and Europe including Battersea Power Station, Waterloo.London, Savarin Prague, Potsdamer Platz Berlin, Trocadero Estate, Wembley Park and Kensington Olympia. Thomas has advised private equity groups on over £1billion of acquisitions and retained mandates for Third Space, Wahaca, Rosa’s Thai, Chipotle and Puttshack.<br>

Thomas is a member of RICS and a Committee Member of the Leisure Property Forum.
          




        </div>
      </div>
      <div class="tab">
        <input type="checkbox" id="chck2">
        <label class="tab-label" for="chck2"><h2>
          
          Justin Taylor, Co-Founder</h2></label>
        <div class="tab-content">
          Lorem ipsum dolor sit amet consectetur adipisicing elit. A, in!
        </div>
      </div>
    </div>
  </div>

and the CSS is here:

// General

input {
  position: ;
  opacity: 0;
  z-index: -1;
}
// Layout
.row {
  display:flex;
  .col {
    flex:1;
    &:last-child {
      margin-left: 1em;
    }
  }
}
/* Accordion styles */
.tabs {
  border-radius: 0px;
  overflow: hidden;
}
.tab {
  width: 100%;
  color: ;
  overflow: hidden;
  &-label {
    display: flex;
    justify-content: space-between;
    padding: 1em;
    background: ;
    font-weight: bold;
    border-bottom: 1px solid #f7b8a1; 
  	padding-bottom:20px;
    cursor: pointer;
/* Icon */
    &:hover {
      background: ;
    }
    &::after {
      content: "\276F";
      width: 1em;
      height: 1em;
      text-align: center;
      transition: all .35s;
    }
  }
  &-content {
    max-height: 0;
    padding: 0 0em;
    color: ;
    background: ;
    transition: all .35s;
  }
  &-close {
    display: flex;
    justify-content: flex-end;
    padding: 1em;
    font-size: 0.75em;
    background: ;
    cursor: pointer;
    &:hover {
      background: ;
    }
  }
}

// :checked
input:checked {
  + .tab-label {
    background: ;
    &::after {
      transform: rotate(90deg);
    }
  }
  ~ .tab-content {
    max-height: 100vh;
    padding-top: 10px;
  }
}

Many thanks,
James

Link to comment
  • 0

If you use Personal Plan, you can use above code

If you use Business Plan or higher + have budget, you can use this &nbsp;Accordion plugin. You can achieve above easier with Image Block + Text Block.

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 0
On 9/4/2021 at 12:30 AM, alejoreinoso said:

Hello, 

I tried this example and it works, but  mobile version go to hell. Is there any extra code to solve this mobile problem? Or the best way is to buy a plugin? Thank you. 

Hi,

What problem on mobile? Can you describe & share link to page where you have problem?

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 0
On 10/12/2021 at 2:26 AM, alejoreinoso said:

Thank you @tuanphan for the answer. Sorry for the delay but client change his mind so I solved the problem. 
Now I am trying to look for some guide (or maybe someone who can do it for us) to have a section where we can compare some products , best example, something like this: https://www.apple.com/iphone/compare/

Is there a way to do it on Squarespace?

I think this is require a lot of code. You should post this on some FB groups to hire some devs

  • Squarespace Customization Resource Group
  • Squarespace Community

(I don't offer service)

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 0

I used this code and it works great. However; I notice in this example the checkbox isn't appearing, but on mine there is a visible checkbox which I would prefer wasn't there. (see attached) When I isolate the "checkbox" input in the code and remove it the accordion no longer opens. Is there a way I can remove or hide the checkbox?

 

Thank you!

Screen Shot 2021-12-15 at 1.09.29 PM.png

Link to comment
  • 0
On 12/16/2021 at 1:09 AM, laurensmithart said:

I used this code and it works great. However; I notice in this example the checkbox isn't appearing, but on mine there is a visible checkbox which I would prefer wasn't there. (see attached) When I isolate the "checkbox" input in the code and remove it the accordion no longer opens. Is there a way I can remove or hide the checkbox?

 

Thank you!

Screen Shot 2021-12-15 at 1.09.29 PM.png

If you share link to page in screenshot, we can give the code to hide checkbox.

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 0
On 12/21/2021 at 12:23 AM, laurensmithart said:

Add to Design > Custom CSS

/* Hide tab input */
div.tabs .tab input {
    opacity: 0;
}

 

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 0
On 1/10/2022 at 11:59 PM, laurensmithart said:

One more question... Is there a way to make this two columns? I keep trying to split the code up and place the blocks next to each other but when I view it live it is all one column.

Use this code

/* product recommendations */
@media screen and (min-width:768px) {
.tabs {
    display: grid;
    grid-template-columns: repeat(2,1fr);
}
}

 

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 0
17 hours ago, tuanphan said:

Use this code

/* product recommendations */
@media screen and (min-width:768px) {
.tabs {
    display: grid;
    grid-template-columns: repeat(2,1fr);
}
}

 

The code works great for the columns; however when I click on an item in the list it not only opens itself but another item as well. Can you check the glitch out and let me know if there's any code to correct this?

https://www.thehost.co/product-recommendations

 

Link to comment
  • 0
On 1/13/2022 at 5:42 AM, laurensmithart said:

The code works great for the columns; however when I click on an item in the list it not only opens itself but another item as well. Can you check the glitch out and let me know if there's any code to correct this?

https://www.thehost.co/product-recommendations

 

Remove above & try this new code

/* product recommendations */
@media screen and (min-width:768px) {
.tabs {
    column-count: 2;
}
}

 

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 0
On 3/8/2022 at 8:11 AM, alyssazack said:

Hi, When I add this code for the accordion block with images it messes up my text blocks across the whole website. Please help!

https://chartreuse-armadillo-lwys.squarespace.com/menu

password: TCR-2022

A lot of code in this topic. Which code did you use?

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

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...