Jump to content

Accordion block expand on desktop, not on mobile (help)

Go to solution Solved by tuanphan,

Recommended Posts

I'm trying to expand the accordions in my footer by default, only on screens above 992px, and have the accordions closed by default on screens less than 992px (mobiles, tablets, etc). The code provided here (https://forum.squarespace.com/topic/213605-how-can-i-display-an-open-accordion-block-item-by-default/?do=findComment&comment=537793) works great for the previous goals, but after adding it I cannot close the accordions on desktop, so they are stuck open.

I'm just wondering if there is any way of expanding the footer accordions on page load, by default, but still allowing the accordions to be closed after the initial page load. You can find my website here: https://piccolo-parakeet-wae7.squarespace.com/

Thanks in advance for reading, and for any advice you can provide.

The css I've used for my footer is below:

//footer font styling

section[data-section-id="6525721f7e51e4600e4a93ab"] {

.accordion-item__title {

   font-size: 0.85em !important;

    }

  //accordion plus sizing

   .accordion-block .plus__vertical-line, .accordion-block .plus__horizontal-line {

      width: 0.8em;

      }

  //don't expand accordion on mobile

   @media screen and (min-width:992px) {

      .sqs-block-accordion .accordion-item__dropdown {

    display: block;

        }

    }

}

Edited by srmdesign
missed word
Link to comment
  • Replies 2
  • Views 1.5k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution

 Add to Website Tools (under Not Linked) > Code Injection > Footer

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
jQuery(document).ready(function($) {
if ($(window).width() > 992) {
$('.fe-655b343efbbed21836ef23fb li').attr('data-is-open','true');
$('.fe-655b343efbbed21836ef23fb .accordion-item__dropdown').addClass('accordion-item__dropdown--open');
}
});
</script>

 

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

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.