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

How to Expand/Collapse a Repeating Item

I've followed the example here and my code is below. When the checkbox in a repeating item is clicked, the textarea shows/hides as expected. However, (a) is overlaps the +Add and Modify controls on the repeating section, and/or (b) is buried under the z-order of subsequent repeating items in the same list. What I want is for the entire repeating list to "drop-down" underneath any particular show textarea so things are readable and the repeating list controls are still usable (see the D&D 5e character sheet for an example of what I want.) How do I do this? The HTML: <div class="sheet-abilities"> <div class="no-grid"> <h3>Skills:</h3> <fieldset class="repeating_skills"> <div> <label>Name: <input type="text" class="skill-name" value="[empty slot]" name="attr_skill_name"/></label> <label>Rank:</label> <input type="number" value="1" name="attr_skill_rank"/> <label>Throw:</label> <input type="number" value="11" name="attr_skill_throw"/> <button type="roll" value="/roll 1d20>@{skill_throw}" name="roll_skill_throw"></button> <input type="checkbox" class="sheet-toggle-show" /> <div class="sheet-body"><textarea class="sheet-body" name="attr_skill_description"></textarea></div> </div> </fieldset> </div> </div> The CSS: .sheet-columns { display: flex; justify-content: space-between; width: 400px; } .sheet-columns > * { flex: 1; } input.sheet-toggle-show:not(:checked) ~ div.sheet-body, input.sheet-toggle-hide:checked ~ div.sheet-body { display: none; } (P.S. Any way to do the CSS without flex? I'm using grid for layout. Does it really matter if it works?)
1588276392
GiGs
Pro
Sheet Author
API Scripter
You dont need to use flex - you could use grid or even block. I'm not following what you mean here: What I want is for the entire repeating list to "drop-down" underneath any particular show textarea The way you have it set up looks like only the text area (and its containing div, which is unneccessary btw) is being hidden and shown. Do you want the labels, inputs, and button above the checkbox to also be hidden? Also in your CSS, you have two ways of hiding the textbox: input.sheet-toggle-show:not(:checked) ~ div.sheet-body, input.sheet-toggle-hide:checked ~ div.sheet-body { why are they both there? The CSS above that refers to sheet-columns , but there is no class by that name in your code. Is columns one of the inbuilt roll20 styles (if so, most people stop using them after a while which is why i cant remember), and if not, what's it's relevance?
I just copy-pasted the example from&nbsp; <a href="https://wiki.roll20.net/CSS_Wizardry#Show.2FHide_Areas" rel="nofollow">https://wiki.roll20.net/CSS_Wizardry#Show.2FHide_Areas</a> , so there's some extra stuff in the CSS that's not relevant. I'm not using the second hiding method. Here's some updated CSS: input.sheet-toggle-show:not(:checked) ~ div.sheet-body { display: none; } The way you have it set up looks like only the text area (and its containing div, which is unneccessary btw) is being hidden and shown. Do you want the labels, inputs, and button above the checkbox to also be hidden? No, only the textarea. The default textarea style seems to be "full width", so it automatically wraps below my other controls - I could use a &lt;br/&gt; to be more explicit. Essentially, I want the other labels, inputs, and buttons to always be visible, and the checkbox to allow me to show/hide additional stuff, like a description field that can be populated with details from the rule-book. This would keep the UI simple for the player, and then they could click the checkbox (or a gear icon) to see the detailed explanation in the &lt;textarea&gt;.
1588280046
GiGs
Pro
Sheet Author
API Scripter
In that case, what CSS do you have applying to that repeating section, and its parts?
.sheet-no-grid { margin-bottom: 10px; } /* Support for tabbed sections */ .sheet-overview, .sheet-abilities, .sheet-equipment, .sheet-journal { display: none; } /* show the selected tab */ .sheet-tabstoggle[value="overview"] ~ div.sheet-overview, .sheet-tabstoggle[value="abilities"] ~ div.sheet-abilities, .sheet-tabstoggle[value="equipment"] ~ div.sheet-equipment, .sheet-tabstoggle[value="journal"] ~ div.sheet-journal { display: block; } label { display: inline; font-size: 1em; font-weight: normal; line-height: 26px; margin: 0px; max-width: initial; padding: 0px; text-align: initial; width: auto; } input { width: 200px; } /* Remove spinners on Chrome, Safari, Edge, Opera */ input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; } /* Remove spinners on Firefox */ input[type=number] { -moz-appearance: textfield; } /* Default style applied to input[type=number] fields to force fixed custom width */ input[type=number] { text-align: center; } input[type=checkbox] { width: 20px; } input.sheet-toggle-show:not(:checked) ~ div.sheet-body { display: none; } input[type=text].sheet-skill-name { width: 400px; } .repitem { height: 2.5em; } I believe these are all the styles in my CSS that apply to the above HTML.