Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Outbreak: Deep Space] Need help with code to toggle show/hide

1489636315

Edited 1489636377
I want to create a tabbed interface for my character sheet.  On its own it is very long but could easily be grouped up into tabs.  I've tried to reverse engineer other sheets and research on the internet but I am having trouble actually getting it to work.  All I need is a button that I can stylize with CSS at the top.  But when clicking on it I would like it to change appearance, hide all divs on the page except the chosen one, and make the selected div visible.  Any assistance would be greatly appreciated!  I'm not sure if the sheet is live on Roll20 yet, I put in a pull request earlier today.  I can link the code to anyone interested.
1489737551
Loki
Sheet Author
take a look at this post by Brian on doing tabs. Note that most of the CSS is to turn the radioboxes into buttons, the only required CSS for it to work is: div.sheet-tab-content { display: none; } input.sheet-tab1:checked ~ div.sheet-tab1, input.sheet-tab2:checked ~ div.sheet-tab2, input.sheet-tab3:checked ~ div.sheet-tab3, input.sheet-tab4:checked ~ div.sheet-tab4 { display: block; } This will hide any divs with the class sheet-tab-content and then show only those divs with the class sheet-tabX where the matching radiobox with the same class is checked. Make sure the inputs are in the same parent as the divs used to show/hide things are. This <div> <input type="radio" name="attr_tab" class="sheet-tab1" checked="true"/> <input type="radio" name="attr_tab" class="sheet-tab2" /> <div class="sheet-tab-content sheet-tab1"> tab 1a </div><!-- this will show --> <div class="sheet-tab-content sheet-tab2"> tab 2 </div> <div class="sheet-tab-content sheet-tab1"> tab 1b </div><!-- this will also show --> </div> will work, while this <div> <input type="radio" name="attr_tab" class="sheet-tab1" checked="true"/> <input type="radio" name="attr_tab" class="sheet-tab2" /> </div> <div> <div class="sheet-tab-content sheet-tab1"> tab 1a </div> <div class="sheet-tab-content sheet-tab2"> tab 2 </div> <div class="sheet-tab-content sheet-tab1"> tab 1b </div> </div> won't. Thought, this can be used to make multiple layers of tabs: <div> <input type="radio" name="attr_tab" class="sheet-tab1" checked="true"/> <input type="radio" name="attr_tab" class="sheet-tab2" /> <div class="sheet-tab-content sheet-tab1"> tab 1a </div><!-- this will show --> <div class="sheet-tab-content sheet-tab2"> tab 2 </div> <div class="sheet-tab-content sheet-tab1"><!-- this will also show --> <input type="radio" name="attr_tab2" class="sheet-tab1" /> <input type="radio" name="attr_tab2" class="sheet-tab2" checked="true" /> <div class="sheet-tab-content sheet-tab1"> tab 1b.1 </div> <div class="sheet-tab-content sheet-tab2"> tab 1b.2 </div><!-- this will show but only while the parent also is shown --> </div> </div>
Loki, Thank you so much.  I think the link you put in the beginning is dead?  Leads to a blank tab for me.  But great explanation, I really appreciate the help!  Could you provide some assistance on how to modify the look of them to be tabs instead of radio buttons?
I think he meant to link to this post in the CSS Wizardry thread: <a href="https://app.roll20.net/forum/permalink/889704/" rel="nofollow">https://app.roll20.net/forum/permalink/889704/</a>
Rabulias, Thanks so much!