Accordion: disable content jumping
-
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;
} -
Awesome. Works perfectly! Thanks a lot!
-
@dennisbern hey, I really like the way you have setup an accordion, is this via a plugin or custom code? It works really smoothly.
-
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> -
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.
-
@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> -
@arminunruh Thanks a lot. Works also perfect!
-
@arminunruh @dennisbern cheers!
4/11
Need custom programming for your Lay Theme site?
I regularly add new features to Lay Theme for free, based on user feedback. But if you or your client need something more specific, I’m happy to offer custom paid programming tailored to your project.
Email info@laytheme.com with the subject "Custom paid programming for Lay Theme" and a short description of what you need — I’ll reply with a cost estimate.
Custom features I build often make it into future Lay Theme updates, so your idea might benefit the whole community.
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