I’ve been trying to create something on my main page, but I’m stuck. The idea is to have four categories (text), and when I click on one, the corresponding images appear. For example, if I click on “Illustrations,” the illustrations should appear, but if I then click on “Hobbies,” the illustrations should disappear and be replaced by the hobbies.
I’ve managed to get the images to appear, but the categories just overlap each other! How can I make one animation stop when another begins?
this is only possible with custom code and would require some css/ javascript coding.
With inbuild RM widgets this is only possible if you have 2 tabs.
Thank you a lot, after some research and typing I did find how to code it!
Besides, maybe it’s obvious and I’m a bit slow, but: How do you put pictures in the code line in the widget tool? My code works, but I can’t find how to insert the images in my code!
It sounds like you’re on the right track, but the issue is that the images for different categories are overlapping because the “opacity” animation doesn’t necessarily hide the elements, it just makes them transparent. To fix this, you can use a combination of opacity and display properties. Here’s how you can do it:
CSS Display Property: Along with setting the opacity, you’ll want to set the display property to none when an image group is inactive and block (or flex) when it’s active. This way, the images won’t just be invisible, but they’ll also stop occupying space on the page.
JavaScript for Triggering: Use JavaScript to detect when a category is clicked and then apply both opacity and display changes for the corresponding image group.
Here’s an example of how you could structure it:
css
Copy code
/* Initially hide all categories */
.category {
display: none;
opacity: 0;
transition: opacity 0.5s ease;
}
/* Active class to show the current category */
.active {
display: block;
opacity: 1;
}
This way, when you click on a category, it will hide the other images and show only the ones you want. Hope this helps!
By the way, if you’re ever looking to take your visuals to the next level with professional animations, check out Illustration Services for stunning Illustration services. They can really make your project stand out!