srmdesign Posted December 19, 2023 Share Posted December 19, 2023 (edited) 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 December 19, 2023 by srmdesign missed word Link to comment
Solution tuanphan Posted December 21, 2023 Solution Share Posted December 21, 2023 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
srmdesign Posted December 21, 2023 Author Share Posted December 21, 2023 Thank you very much, works great! The only thing was the fluid engine id (fe) was targeting the accordion in the main page body, instead of the footer, but I've changed the id and it works great now. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment