For those looking to create responsive tabbed content, in a very simple way check this out!
https://melwiersma06.wixsite.com/mysite-2
You can have as many tabs as you like, the code is duplicated.
Step 1: Depending on how many tabs you would like to have create the appropriate number of buttons for them. (In my case I have 3)
Step 2: You’ll need to create the same number of container boxes for each content topic. (You can make them any style you’d like) You can fill them with any content that you would like, text, pictures, videos, etc., you just need to make sure that each content piece is attached to their appropriate box. (it will light up blue when you do it)
Step 3: You may run into the same thing as I did for this: You want to sort of layer the boxes on top of each other. You’ll find that if some boxes are smaller and some are bigger it will try to attach them to each other. You can eliminate this by the following: 1. Either make them the same size so it isn’t possible for the boxes to attach and leave them that way or if you want them different sizes you can adjust the size of each box after you layer them.
Step 4: *VERY IMPORTANT You need to make sure that your boxes are “hidden upon load” Now, you can leave one of the boxes (say your main details) un hidden so that that box will be there when the page loads, but it’s up to you. Note that that is the third section of code
Step 5: In the properties pane you’ll want all of your boxes to be set to “on click” then by using code we can tell that click what to do.
Step 6: Coding. (This code is duplicated, so I will explain in once.)
You’ll notice when you activate the “on click” event a line of code automatically appears. This is where we will manipulate our code from.
To start: this is the line that automatically appears: export function button1_click() {
So when we click this button we want 2 things to happen:
- We want the first box to open
- We want all of the other boxes to close. (This way the content doesn’t overlap and look weird)
This is what this looks like:
export function button_1 click() {
$w (‘#box1’) .show ();
$w (‘#box2’) .hide ();
$w (#box3’) .hide ();
}
That’s it! **Note that I have applied the fade animation to each box. You can do that before coding. It also doesn’t affect the code in any way by applying or not applying the animation. Hope this helps!!
Again, feel free to look at the site to see what your final product could look like!
Drop a comment, if something doesn’t make sense and I will do my best to explain!
Cheers!