Spoiler Button Tabs in Cathedris | World Anvil

Cathedris Themesong

Spoiler Button Tabs

To buy this -- wait a minute, you don't need to buy this! This is FREE! Though, it's still limited to only those with Grandmaster or above membership, because it uses containers.

Stats at a glance


 
BS5 Support
BS5 and BS3 compatible!

 
BBCode wordcount
Roughly 50 words

CSS line count
Roughly 200 lines
Price
FREEEEEE

Bundle Options
It's free :D




      These tabs are done through piggybacking off of spoilers, and applying animations to siblings all within a shared container. It's got a lot of CSS to go with it, but it's surprisingly not too complicated -- just a lot of repetative rules to make sure things move properly. The interesting part about these is that they don't use the spoiler content at all -- in fact, it's all hidden via CSS.   I've kept everything fairly simply styled, because that can be modified as you so choose, anyways. It's slightly complicated to add or remove tabs in the CSS, but once you understand what you're looking at, it's not too bad!   Check the tabs out below here, and then below the tabs will be the CSS and BBcode. Because this features extensive use of containers, these tabs will only work for Grandmasters and above.  

The Tabs

Tab 1
Tab 2
Tab 3
Tab 4
Tab 5
Tab 6

THIS IS CONTENT IN TAB 1

Woo look at it, it supports whatever you want, like columns and pictures -- but not more spoilers.
 

COLUMN-1-CONTENT

This is a quote in a column that is on tab 1

COLUMN-2-CONTENT

COLUMN-3-CONTENT

This is an aloud in a column that is on tab 1

Lorem Ipsum

Aliquam ut justo hendrerit, luctus quam a, laoreet arcu. Cras elit velit, ornare at velit id, gravida mattis neque. In consequat metus nec magna convallis imperdiet at fermentum odio. Sed non lorem nec dui malesuada porttitor eu vitae justo. Pellentesque a erat venenatis, convallis tortor non, imperdiet lacus. Donec quis euismod justo. Aliquam erat volutpat.   Aenean vel mollis eros. Etiam nec sapien metus. Pellentesque id cursus metus. Nam tristique luctus sollicitudin. Fusce venenatis orci interdum, bibendum nisl non, dapibus ipsum. Sed sit amet sodales nunc. Aliquam sit amet risus eget sapien lacinia ultrices. Proin a luctus nulla. Aliquam ut justo hendrerit, luctus quam a, laoreet arcu. Cras elit velit, ornare at velit id, gravida mattis neque. In consequat metus nec magna convallis imperdiet at fermentum odio. Sed non lorem nec dui malesuada porttitor eu vitae justo. Pellentesque a erat venenatis, convallis tortor non, imperdiet lacus. Donec quis euismod justo. Aliquam erat volutpat.   Aenean vel mollis eros. Etiam nec sapien metus. Pellentesque id cursus metus. Nam tristique luctus sollicitudin. Fusce venenatis orci interdum, bibendum nisl non, dapibus ipsum. Sed sit amet sodales nunc. Aliquam sit amet risus eget sapien lacinia ultrices. Proin a luctus nulla.

Small column

Aenean vel mollis eros. Etiam nec sapien metus. Pellentesque id cursus metus. Nam tristique luctus sollicitudin. Fusce venenatis orci interdum, bibendum nisl non, dapibus ipsum. Sed sit amet sodales nunc. Aliquam sit amet risus eget sapien lacinia ultrices. Proin a luctus nulla.

Big Column

Aenean vel mollis eros. Etiam nec sapien metus. Pellentesque id cursus metus. Nam tristique luctus sollicitudin. Fusce venenatis orci interdum, bibendum nisl non, dapibus ipsum. Sed sit amet sodales nunc. Aliquam sit amet risus eget sapien lacinia ultrices. Proin a luctus nulla.

Big column

Aenean vel mollis eros. Etiam nec sapien metus. Pellentesque id cursus metus. Nam tristique luctus sollicitudin. Fusce venenatis orci interdum, bibendum nisl non, dapibus ipsum. Sed sit amet sodales nunc. Aliquam sit amet risus eget sapien lacinia ultrices. Proin a luctus nulla.

Small Column

Aenean vel mollis eros. Etiam nec sapien metus. Pellentesque id cursus metus. Nam tristique luctus sollicitudin. Fusce venenatis orci interdum, bibendum nisl non, dapibus ipsum. Sed sit amet sodales nunc. Aliquam sit amet risus eget sapien lacinia ultrices. Proin a luctus nulla.

Bullet Points

  • these
  • are
  • a
  • list
  • of
  • things
  • to
  • fill
  • out
  • this
  • tab
  • And whatever else you might want to fit in here!

    These tabs are very flexible and can fit almost anything in.

    Choose one of the 6 tabs above!

     



      This is content below the tabs. The tab container has a base height of 500px -- this can be changed within the CSS to match your content, however. The tabs themselves can have the same, or different heights, depending on your preferences! I personally think it works better if they're all the exact same size, but that's up to you. I wanted to find some way of making all the tabs automatically match the height of the longest one, but as far as I can tell, that's not possible. If you know of a way, please let me know!  
    Throwing my hat in the ring with attempting to replicate some JS style tabs, using nothing but the CSS we can modify!

       

    The Code

     
    NOTE: You will need to ensure to turn off the "Visibility Toggle" option on your world configuration options in order for these tabs to work. You'll find the option under Configuration > Display > Visibility Toggle
     

    CSS

    Note: You will need to remove the space between the / and the * on the comments in the CSS. The space needed to be added so that they'd show up on here.
     
    / *THIS CODE IS FOR JS STYLE TABS* /
    / *These are the animations that bring tabs forward and backward* /
    @keyframes forward { from { } to { z-index: 5;} } @keyframes back { from { } to { z-index: -10;} }  
    / *This controls the styling of the tab buttons* /
    .tabholder .spoiler-button { display: inline-block; background: gray; color: black !important; border-left: 3px solid #a08264; border-right: 3px solid #a08264; border-top: 3px solid #a08264; }
    / *This is the styling for the button/tab you are focused on* /
    .tabholder .spoiler-button:focus { background: lightgray; }  
    / *This controls the styling of the tabs, including the base blank tab. Make sure to leave all of the animation rules alone.* /
    .tab1, .tab2, .tab3, .tab4, .tab5, .tab6, .blanktab { animation-name: forward; animation-duration: 1ms; animation-fill-mode: forwards; animation-play-state: paused; background: lightgray; color: black; padding: 15px; margin-top: -11px; width: 100%; position: absolute; display: block; z-index: -1; border-left: 3px solid #a08264; border-right: 3px solid #a08264; border-bottom: 3px solid #a08264; border-radius: 0px 10px 10px; }  
    / *Provides a base Z-index and background colour to the blank(first) tab* /
    .blanktab { z-index: 0; background: gray; }  
    / *Controls size and positioning of the entire tab container, as well as headers in the next selector* /
    .tabholder { margin-bottom: 50px; min-height: 300px; height: 500px; position: relative; width: 100%; } .tabholder h2, .tabholder h3, .tabholder h4, .tabholder h5{ color: black !important; }  
    / *Hides the pesky spoiler button content -- we don't need those, we just want the buttons.* /
    .tabholder .well, .tabholder .collapse.in, .tabholder .collapsing, .tabholder .card { display: none; }  
    / *From this point on, this CSS is for connecting spoiler buttons to tabs. Each section will have rules for a button bringing its corresponding tab to the front, while sending each other to the back. You shouldn't have to change any of the actual rules in here, but just modify the selectors when you want to add or remove tabs.* /   / *This section takes the FIRST spoiler button when clicked on, and brings the FIRST tab out* /
    .tabholder .spoiler-button:nth-child(1):focus ~ .tab1 { animation-name: forward; animation-duration: 0s; animation-fill-mode: forwards; animation-play-state: running; }  
    / *This section takes the FIRST spoiler button when clicked on, and sends every other tab to the back. If you want to add or remove tabs, you need to make sure you have this section properly filled out.* /
    .tabholder .spoiler-button:nth-child(1):focus ~ .tab2, .tabholder .spoiler-button:nth-child(1):focus ~ .tab3, .tabholder .spoiler-button:nth-child(1):focus ~ .tab4, .tabholder .spoiler-button:nth-child(1):focus ~ .tab5, .tabholder .spoiler-button:nth-child(1):focus ~ .tab6 { animation-name: back; animation-duration: 0s; animation-fill-mode: forwards; animation-play-state: running; }  
    / *This section takes the SECOND spoiler button when clicked on, and brings the SECOND tab out. I'm sure you can see the pattern now. The nth-child spoiler buttons count upwards by two, so make sure to pay attention to that when modifying and adding/removing more tabs.* /
    .tabholder .spoiler-button:nth-child(3):focus ~ .tab2 { animation-name: forward; animation-duration: 0s; animation-fill-mode: forwards; animation-play-state: running; } .tabholder .spoiler-button:nth-child(3):focus ~ .tab1, .tabholder .spoiler-button:nth-child(3):focus ~ .tab3, .tabholder .spoiler-button:nth-child(3):focus ~ .tab4, .tabholder .spoiler-button:nth-child(3):focus ~ .tab5, .tabholder .spoiler-button:nth-child(3):focus ~ .tab6 { animation-name: back; animation-duration: 0.5s; animation-fill-mode: forwards; animation-play-state: running; }   .tabholder .spoiler-button:nth-child(5):focus ~ .tab3 { animation-name: forward; animation-duration: 0s; animation-fill-mode: forwards; animation-play-state: running; } .tabholder .spoiler-button:nth-child(5):focus ~ .tab1, .tabholder .spoiler-button:nth-child(5):focus ~ .tab2, .tabholder .spoiler-button:nth-child(5):focus ~ .tab4, .tabholder .spoiler-button:nth-child(5):focus ~ .tab5, .tabholder .spoiler-button:nth-child(5):focus ~ .tab6 { animation-name: back; animation-duration: 0s; animation-fill-mode: forwards; animation-play-state: running; }   .tabholder .spoiler-button:nth-child(7):focus ~ .tab4 { animation-name: forward; animation-duration: 0s; animation-fill-mode: forwards; animation-play-state: running; } .tabholder .spoiler-button:nth-child(7):focus ~ .tab1, .tabholder .spoiler-button:nth-child(7):focus ~ .tab2, .tabholder .spoiler-button:nth-child(7):focus ~ .tab3, .tabholder .spoiler-button:nth-child(7):focus ~ .tab5, .tabholder .spoiler-button:nth-child(7):focus ~ .tab6 { animation-name: back; animation-duration: 0s; animation-fill-mode: forwards; animation-play-state: running; }   .tabholder .spoiler-button:nth-child(9):focus ~ .tab5 { animation-name: forward; animation-duration: 0s; animation-fill-mode: forwards; animation-play-state: running; } .tabholder .spoiler-button:nth-child(9):focus ~ .tab1, .tabholder .spoiler-button:nth-child(9):focus ~ .tab2, .tabholder .spoiler-button:nth-child(9):focus ~ .tab3, .tabholder .spoiler-button:nth-child(9):focus ~ .tab4, .tabholder .spoiler-button:nth-child(9):focus ~ .tab6 { animation-name: back; animation-duration: 0s; animation-fill-mode: forwards; animation-play-state: running; }     .tabholder .spoiler-button:nth-child(11):focus ~ .tab6 { animation-name: forward; animation-duration: 0s; animation-fill-mode: forwards; animation-play-state: running; } .tabholder .spoiler-button:nth-child(11):focus ~ .tab1, .tabholder .spoiler-button:nth-child(11):focus ~ .tab2, .tabholder .spoiler-button:nth-child(11):focus ~ .tab3, .tabholder .spoiler-button:nth-child(11):focus ~ .tab4, .tabholder .spoiler-button:nth-child(11):focus ~ .tab5 { animation-name: back; animation-duration: 0s; animation-fill-mode: forwards; animation-play-state: running; }

    BBCODE

    The BBcode is rather simple! There is one overall container, "tabholder", that holds everything. The first things entered in this container are the spoiler buttons -- these are the buttons that will let us bring tabs forward and backward. You don't need any content in them, but make sure to give each of them a name, like how I have them named Tab 1, 2, 3, etc.   After that, it's a simple matter of putting the content you want into the corresponding containers afterwards. Hopefully I've named everything clearly enough that it makes sense which is which, and which button interacts with which tab.
     
    [container:tabholder] [spoiler]|Tab 1[/spoiler] [spoiler]|Tab 2[/spoiler] [spoiler]|Tab 3[/spoiler] [spoiler]|Tab 4[/spoiler] [spoiler]|Tab 5[/spoiler] [spoiler]|Tab 6[/spoiler] [container:tab1]   -tab 1 content goes here-   [/container] [container:tab2]   -tab 2 content goes here-   [/container] [container:tab3]   -tab 3 content goes here-   [/container] [container:tab4]   -tab 4 content goes here-   [/container] [container:tab5]   -tab 5 content goes here-   [/container] [container:tab6]   -tab 6 content goes here-   [/container] [container:blanktab]   -this is where you put the content that shows before any tabs are selected-   [/container] [/container]
     

    Final notes

    I've attempted to keep this as barebones as possible, so that further styling can be applied to it. I've tried to only include CSS rules that are absolutely necessary, plus base styling to make them readable.   If you're a CSS-wizard, it should be easy enough to take this and build some neat things off of it. Spoiler buttons allow us to get up to some really fun shenanigans!   Let me know if this seems useful or neat, and if you end up using it, I'd absolutely love to see your implementation!  
    As with my other CSS add-on creations, I would very much appreciate credit or even a link back to this article if possible! If you've enjoyed it, I'd love for others to be able to easily find this page and have a chance to implement it themselves as well :)
         


    Comments

    Please Login in order to comment!
    Jul 14, 2021 07:40 by R. Dylon Elder

    OH MY GOD! You did it. You cracked the code! ive been wanting something like this for ages! well done storm!

    Jul 14, 2021 22:26 by Stormbril

    WOOO! INFINITE POWER VIA SPOILER BUTTONS!   Let me know if/how you end up using these :D

    Jul 15, 2021 00:58 by R. Dylon Elder

    Will do. Soooooon. I must learn how this thing works first XD such sorcery is beyond mere mortals like myself.

    Jul 17, 2021 11:49

    "Hippity hoppity your code is now my property"   This is something beyond awesome. Great work as always, css wizard of WA.

    Jul 17, 2021 22:50 by Stormbril

    Huzzah! Thank you! :D   One thing I forgot to mention at the top of this article, but because this uses containers, only Grandmasters and above can use it, sadly D:

    Jul 28, 2021 16:45

    The time has come.   Now I have unlimited Power!   Meh, not really, but now I can use your tabs. :D

    Jul 28, 2021 17:38 by Stormbril

    UNLIMITED POWER!   Congrats on the upgrade, have fun with all the lovely things you can do with containers :D

    Jul 30, 2021 13:10 Private

    I recently integrated the table in one of my articles and it's freaking awesome (and useful af)!   https://www.worldanvil.com/w/dvds-hertzbube/a/gebiete-article?preview=true (scroll to the end)

    Jul 30, 2021 21:08 by Stormbril

    Woah, that looks fantastic! I'm so excited it worked out for you, what an excellent use of them :D I'm really glad that image carousels and organization charts work so well within it too!

    Sep 9, 2021 22:52 by Stormbril

    Hey Hertzbube! I'm doing some editing and cleaning up of some of my CSS showcase articles, and standardizing the layouts of them. I was wondering if you'd be okay with me putting your article at the bottom of this page under the "In Article Use Example" section!

    Sep 30, 2021 15:54

    Sorry for the late answer. You Idea here is great and it would be an honor for me to see my article here as example.

    Oct 5, 2021 06:12 by Stormbril

    No worries at all! I'm very happy to hear that, and I'll add yours as an example now :D

    Sep 12, 2021 14:32

    Thank you soooooo much!! I needed this so much, but couldn't made the code myself. I was customizing it a bit and I was able to hide the text from other tabs, because i really wanted a transparent background. So the text from the tabs weren't overlapping each other. Only the blanktab wouldn't work with a transparent background (a solution would be a coloured background). But again, THANK YOU....Now I can make my world even more beautiful <3 <3

    Sep 13, 2021 03:37 by Stormbril

    You are absolutely welcome! I'm very happy it's useful to you! :D   If you want, you can give me a link to an article where you've got the tabs working, and I can put it at the bottom of this article as an example use of them -- if you like, that is! No worries if not, I just like showing how people use the things <3

    Jun 20, 2022 00:09 by Amelia Nite

    I love this CSS, but the second I tried to implement it into one of my articles, the spoilers still try to open like they're regular spoilers. And this is just by copy-pasting the CSS and BBcode straight from this article (the CSS is in the article CSS), and I have no theme chosen for my world. I also made sure all the spaces between the / and the * were closed.

    Jun 20, 2022 00:30 by Stormbril

    Oh no! Sometimes that happens. If you want, you can DM me on discord and I can give you the exact CSS I'm using on this page, or link me a test article on your world so I can poke around with the inspector and see what's up.

    Jul 26, 2022 01:37

    I can get some neat things done with CSS, but was never able to figure out tabs. Thanks for providing this CSS to the community! I already have it styled for my world and it is definitely improving the appearance of my articles! The specific article where I used it is here:https://www.worldanvil.com/w/cairn-sector-chrispy0/a/zilda-marn-s-research-notes-document. Again, thanks!

    Aug 1, 2022 02:16 by Stormbril

    OOOOOO, I love the way you've styled those! I'm so happy this was of use for you :D   If you're alright with it, I'd love to include a block link to that article at the bottom of this one as an example of how someone has used this tech!

    Aug 1, 2022 03:23

    I have no problem with that, go for it! Hopefully it can give others some ideas of their own.

    Jul 31, 2022 19:33 by Anna Katherina

    Why must you fill me with the desire to redo half my world's CSS. How dare you, ha.

    Explore-SigBanner
    If You Like What You Read:
    Buy me a Ko-fi
    Join My Discord
    Aug 1, 2022 13:39 by Anna Katherina

    Psshhaa

    Explore-SigBanner
    If You Like What You Read:
    Buy me a Ko-fi
    Join My Discord
    Mar 13, 2024 05:46 by Jacqueline Yang

    Hey, so I don't know what I'm doing wrong, but I can't seem to use the tabs. I don't understand why this is, but somewhat recently(?) someone used this feature and the tabs just wouldn't work.   I even checked out all the other articles you featured as examples and they wouldn't work either. Could this just be a me thing, because for everyone else the tabs seem to be able to work. To make sure I tried it out in one of my own world's making sure the Visibility Toggle was off, and that didn't work. I clicked each tab several times and nothing changed.   Any idea why this could be happening? Or what even is happening?

    Mar 13, 2024 15:17 by Stormbril

    Oh no! That's really strange. If it's not working across a variety of articles and worlds then it's gotta be something related to your browser -- try disabling various add-ons if you're on firefox or chrome, as that might play with things a bit. Also, I think safari has an issue with these tabs too? I don't have anything made by Apple so I'm unable to test that one.

    Mar 13, 2024 16:32 by Jacqueline Yang

    Yeah, that's what I was thinking too. I am using Safari so that's probably it.   Thanks for the help!

    Mar 13, 2024 17:34 by Jacqueline Yang

    Quick update: tried it out on Firefox and the tabs worked!

    Mar 13, 2024 17:39 by Stormbril

    Great to hear! Well, great that they worked, less great that they don't work on Safari. That's priority #1 to figure out for these things though! I'm just running out of ideas of things to try on that, haha :(

    Mar 13, 2024 18:46 by Jacqueline Yang

    Yeah, CSS is very complicated and there always seems to be something not working.   But I appreciate how hard you work on articles like these, so people like me who have no idea how CSS works can improve the look of their articles!

    Powered by World Anvil