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

Tabs aren't working

The first two tabs show their content, but the last two don't. I've tried to look at the wiki section on CSS but I haven't figured it out yet. I am pretty sure it's a problem with CSS though. Here's my script if anyone wants to try and see what I've missed. Thanks. div.sheet-tab1, div.sheet-tab2, div.sheet-tab3, div.sheet-tab4 { 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; } input.sheet-tab { width: 150px; height: 20px; position: relative; top: 5px; left: 6px; cursor: pointer; z-index: 9999; opacity: 0; display: inline-block; } span.sheet-tab { display: inline-block; margin-left: -150px; /*position: relative;*/ } input.sheet-tab + span.sheet-tab { /*content: attr(title);*/ border: solid 1px #a8a8a8; border-bottom-color: black; text-align: center; display: inline-block; background: #fff; background: linear-gradient(to top, #c8c8c8, #fff, #c8c8c8); width: 150px; height: 20px; font-size: 18px; /*position: absolute;*/ /*top: 12px; left: 13px;*/ display: inline-block; } input.sheet-tab:checked + span.sheet-tab { background: #dcdcdc; background: linear-gradient(to top, #fcfcfc, #dcdcdc, #fcfcfc); border-bottom-color: #fff; } input.sheet-tab:not(:first-child) + span.sheet-tab { border-left: none; } input.sheet-tab2 + span.sheet-tab input.sheet-tab2:checked + span.sheet-tab input.sheet-tab3 + span.sheet-tab { left: 313px; } input.sheet-tab4 + span.sheet-tab { left: 463px; } div.sheet-tab-content { border: 1px solid #a8a8a8; border-top-color: #000; } div.sheet-tab2
1532655745
Andreas J.
Forum Champion
Sheet Author
Translator
What's up with input.sheet-tab3 + span.sheet-tab { left: 313px; } input.sheet-tab4 + span.sheet-tab { left: 463px; } Have you tried removing the left-shift, is it possible they would have pushed the content of the sheet? And you have no code for tab2, just their class names floating there.
Andreas J. said: What's up with input.sheet-tab3 + span.sheet-tab { left: 313px; } input.sheet-tab4 + span.sheet-tab { left: 463px; } Have you tried removing the left-shift, is it possible they would have pushed the content of the sheet? And you have no code for tab2, just their class names floating there. Thanks, I'll try that. To be honest this was all based on the example in the wiki. That  div.sheet-tab2  was there already when I copied it.
1532702747
GiGs
Pro
Sheet Author
API Scripter
Its a good idea to avoid sections like this: input.sheet-tab2 + span.sheet-tab input.sheet-tab2:checked + span.sheet-tab CSS ignores linebreaks and most spaces, so that looks like input.sheet-tab2 + span.sheet-tab input.sheet-tab2:checked + span.sheet-tab Anything other lines after this line will also get added to that line, till you come to something that css recognises as a separator - like a comma or curly brackets. This can have unpredictable effects (especially when you have only the vaguest idea of how CSS works (and you aren't alone in that, believe me)). So if you want to leave text like that in and not do anything with it, its a good idea to end each line with a matching set of braces, at least till you know what you are going to do with those lines, like so: input.sheet-tab2 + span.sheet-tab {} input.sheet-tab2:checked + span.sheet-tab {}
1532711580

Edited 1532711695
Grim G.
Sheet Author
Andreas J. said: What's up with input.sheet-tab3 + span.sheet-tab { left: 313px; } input.sheet-tab4 + span.sheet-tab { left: 463px; } Have you tried removing the left-shift, is it possible they would have pushed the content of the sheet? And you have no code for tab2, just their class names floating there. I removed everything between those two sets of braces and that one line alone at the bottom. No effect. G G said: Its a good idea to avoid sections like this: input.sheet-tab2 + span.sheet-tab input.sheet-tab2:checked + span.sheet-tab CSS ignores linebreaks and most spaces, so that looks like input.sheet-tab2 + span.sheet-tab input.sheet-tab2:checked + span.sheet-tab Anything other lines after this line will also get added to that line, till you come to something that css recognises as a separator - like a comma or curly brackets. This can have unpredictable effects (especially when you have only the vaguest idea of how CSS works (and you aren't alone in that, believe me)). So if you want to leave text like that in and not do anything with it, its a good idea to end each line with a matching set of braces, at least till you know what you are going to do with those lines, like so: input.sheet-tab2 + span.sheet-tab {} input.sheet-tab2:checked + span.sheet-tab {} Ok so I removed every space that seemed to serve no purpose and began adding braces to everything not between them already. There have been no changes and adding them to ones with commas only made things worse. What is the difference between braces and commas anyways? Is it just that you can add commands within the former? This is what it looks like so far. div.sheet-tab1, div.sheet-tab2, div.sheet-tab3, div.sheet-tab4 { 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; } input.sheet-tab { width: 150px; height: 20px; position: relative; top: 5px; left: 6px; cursor: pointer; z-index: 9999; opacity: 0; display: inline-block; } span.sheet-tab { display: inline-block; margin-left: -150px; /*position: relative;*/ } input.sheet-tab + span.sheet-tab { /*content: attr(title);*/ border: solid 1px #a8a8a8; border-bottom-color: black; text-align: center; display: inline-block; background: #fff; background: linear-gradient(to top, #c8c8c8, #fff, #c8c8c8); width: 150px; height: 20px; font-size: 18px; /*position: absolute;*/ /*top: 12px; left: 13px;*/ display: inline-block; } input.sheet-tab:checked + span.sheet-tab { background: #dcdcdc; background: linear-gradient(to top, #fcfcfc, #dcdcdc, #fcfcfc); border-bottom-color: #fff; } input.sheet-tab:not(:first-child) + span.sheet-tab { border-left: none; } input.sheet-tab2 + span.sheet-tab {} input.sheet-tab2:checked + span.sheet-tab {} input.sheet-tab3 + span.sheet-tab {} input.sheet-tab4 + span.sheet-tab {} div.sheet-tab-content { border: 1px solid #a8a8a8; border-top-color: #000; }
1532713805

Edited 1532713864
GiGs
Pro
Sheet Author
API Scripter
A comma groups the current line and the next line together, so you definitely do not want to put curly braces on those lines. I'd recommend reading a primer on CSS. But a style rule will look like this: div.sheet-tab-content { border: 1px solid #a8a8a8; border-top-color: #000; } You put styling rules between the { and }, and the bit before the { is where in the html to apply it. In this example, we are applying some border styles to a div with the name sheet-tab-content. Commas can be used to group style names that all have the same styles applied. For example, you could type: div.sheet-tab1 { display: none; } div.sheet-tab2 { display: none; } div.sheet-tab3 { display: none; } div.sheet-tab4 { display: none; } This applies the styling "display: none" to the divs with the style name sheet-tab1, sheet-tab2, sheet-tab3, and sheet-tab4. But since they all have the same style applied (display: none) you can simplify it to div.sheet-tab1, div.sheet-tab2, div.sheet-tab3, div.sheet-tab4 { display: none; } For complex sheets and special conditions (tabs) this becomes very useful.
I've been doing some trial and error to see if I can find out anything new. So far I've noticed that these lines of code can be removed without any noticeable effects. I had some ideas as to why but nothing I do to it changes the result. Any ideas? input.sheet-tab:not(:first-child) + span.sheet-tab { border-left: none; } input.sheet-tab2 + span.sheet-tab input.sheet-tab2:checked + span.sheet-tab input.sheet-tab3 + span.sheet-tab { left: 313px; } input.sheet-tab4 + span.sheet-tab { left: 463px; }
Ok, never mind. I'm an idiot. Two of my <div>s had the / behind instead of in front. It had nothing to do with CSS.