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

13 answers to this question

Recommended Posts

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

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.

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

Hi @tuanphan,

Just an update on the above as I have been playing around with it this morning. Increasing the max-height in .tab-content from 100vh to 300vh seems to have solved the overflowing issue. 

If you can shed any light on the image alignment though that would be greatly appreciated!

All best,

James

Link to comment
  • 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

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.

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.

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.

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