Accordion: disable content jumping
-
wrote on Apr 3, 2025, 8:59 AM last edited by
Hi all, I have an accordion on my site.
When the page is opened on a desktop page, the content of the oppsite page jumps down the end of the gridder (for mobile this function is perfect). Can I use a CSS code so that this won`t happen?
The page is built like this:
Left side: a stack with "headline text" and below it the "accordion code". on the right side of the gridder a "text block":https://biografie.art/die-eigenen-grenzen-anerkennen-radikal-copy
All the best, Dennis
-
hello!
you could try this Enter this css in "lay options" -> "custom css & html" -> "custom css for desktop":
.accordion-content{
position: absolute;
} -
wrote 20 days ago last edited by dennisbern 20 days ago
Awesome. Works perfectly! Thanks a lot!
-
Awesome. Works perfectly! Thanks a lot!
wrote 20 days ago last edited by@dennisbern hey, I really like the way you have setup an accordion, is this via a plugin or custom code? It works really smoothly.
-
wrote 20 days ago last edited by dennisbern 20 days ago
This is a custom code. Which I actually found in this forum. I think it was a code from @arminunruh
I put it in an edit html box:
<div class="accordion">
<div class="accordion-title _accordion_title">
<span>Title</span>
<span class="plus">+</span>
<span class="minus">-</span>
</div>
<div class="accordion-content _accordeon_laufschrift">
<p>TEXT
</div>
</div> -
wrote 19 days ago last edited by dennisbern 19 days ago
Hey a question about my code :)
I have blue links (desktop version) in my accordion. where can I edit them so that they are black?
Another thing: I want the links to open in a separate tab or window. How can I do that with the HTML code?
-
Links need to have a target blank attribute for them to be opened in a new tab.
target="_blank"
<a href="…" target="_blank">asd</a>
Blue links to black is just CSS.
.accordion a{
color: black!important;
} -
Thanks for providing the code for @alasdair17 , but I think it's missing the JavaScript part.
-
Thanks for providing the code for @alasdair17 , but I think it's missing the JavaScript part.
wrote 11 days ago last edited by@arminunruh True:
<script>
window.laytheme.on('newpageshown', function(){
jQuery(".accordion-title").on("click", function(){
jQuery(this.parentNode).toggleClass("active")
})
})
</script>
<style>
.accordion-title{
cursor: pointer;
}
.accordion .minus, .accordion .plus{
margin-left: 30px;
}
.accordion .minus{
display: none;
}
.accordion .accordion-content{
display: none;
margin-top: 20px;
}
.accordion.active .minus{
display: inline;
}
.accordion.active .plus{
display: none;
}
.accordion.active .accordion-content{
display: block;
}
.accordion-title{
display: inline-block;
}
</style> -
Links need to have a target blank attribute for them to be opened in a new tab.
target="_blank"
<a href="…" target="_blank">asd</a>
Blue links to black is just CSS.
.accordion a{
color: black!important;
}wrote 11 days ago last edited by@arminunruh Thanks a lot. Works also perfect!
-
Thanks for providing the code for @alasdair17 , but I think it's missing the JavaScript part.
wrote 11 days ago last edited by@arminunruh @dennisbern cheers!
I also code custom websites or custom Lay features.
💿 Email me here: 💿
info@laytheme.com
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it