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

CSS alignment conundrum

Hey Everyone, I've got a slightly baffling problem with how my css elements are shaking out. The situation is that I have split my character sheet into 2 boxes which will then run side-by-side in two separate columns. This has been working well for me aside from the fact some of the elements in the second box get shifted when the elements in the first box exceed a certain length. The images below show the two boxes in a vertical alignment to demonstrate what is happening better, but the reason why the solution isn't "put them in the same box" is because they will be shifted over, and this problem persists after it has been moved. ^screenshot of preview ^screenshot of filled out sheet You can see here that the 'assets' repeating field goes underneath the 'growth', 'plot points' and 'additional dice' section, but then shunts down the values section and everything below it (offscreen). It's hard to know what the relevent code here is so I'm going to post a link to the sheet as a whole and post the html and css from the 'growth' section to the end of the values section. <a href="https://github.com/abyssalLegate/Cortex-Drama-Sheet" rel="nofollow">https://github.com/abyssalLegate/Cortex-Drama-Sheet</a> HTML: &lt;div class="box2"&gt; &lt;div class="growth-container"&gt; &lt;div class="growth-header"&gt;Growth&lt;/div&gt; &lt;div class="growth-menu"&gt;d4&lt;/div&gt; &lt;input class="growth-main" type="number" name="attr_growd4"&gt; &lt;div class="growth-menu"&gt;d6&lt;/div&gt; &lt;input class="growth-main" type="number" name="attr_growd6"&gt; &lt;div class="growth-menu"&gt;d8&lt;/div&gt; &lt;input class="growth-main" type="number" name="attr_growd8"&gt; &lt;div class="growth-menu"&gt;d10&lt;/div&gt; &lt;input class="growth-main" type="number" name="attr_growd10"&gt; &lt;div class="growth-menu"&gt;d12&lt;/div&gt; &lt;input class="growth-main" type="number" name="attr_growd12"&gt; &lt;/div&gt; &lt;div class="plot-container"&gt; &lt;h4&gt;&lt;/h4&gt; &lt;h4 class="plot-header"&gt;Plot Points&lt;/h4&gt; &lt;h4&gt;&lt;/h4&gt; &lt;input class="plot-main" type="number" name="attr_plot_points"&gt; &lt;h4&gt;&lt;/h4&gt; &lt;h4 class="dice-header"&gt;Additional Dice&lt;/h4&gt; &lt;input type="checkbox" class="toggle" name="attr_dX_flag" value="1"/&gt; &lt;textarea class="dice-main" type="text" name="attr_dX" value="0"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;div class="value-container"&gt; &lt;h4 class="value-header"&gt;Values&lt;/h4&gt; &lt;h4&gt;&lt;/h4&gt; &lt;h4 class="value-header2"&gt;&lt;/h4&gt; &lt;h4 class="value-header1"&gt;Rating&lt;/h4&gt; &lt;h4 class="value-header1"&gt;Current&lt;/h4&gt; &lt;h4 class="value-header1"&gt;Statement&lt;/h4&gt; &lt;input type="checkbox" class="toggle" name="attr_duty_flag" value="1"/&gt; &lt;div class="value-menu"&gt;DUTY&lt;/div&gt; &lt;select class="value-main" name="attr_dutybase"&gt; &lt;option value="0" selected&gt;-&lt;/option&gt; &lt;option value="d4"&gt;d4&lt;/option&gt; &lt;option value="d6"&gt;d6&lt;/option&gt; &lt;option value="d8"&gt;d8&lt;/option&gt; &lt;option value="d10"&gt;d10&lt;/option&gt; &lt;option value="d12"&gt;d12&lt;/option&gt; &lt;/select&gt; &lt;select class="value-main" name="attr_duty"&gt; &lt;option value="0" selected&gt;-&lt;/option&gt; &lt;option value="d4"&gt;d4&lt;/option&gt; &lt;option value="d6"&gt;d6&lt;/option&gt; &lt;option value="d8"&gt;d8&lt;/option&gt; &lt;option value="d10"&gt;d10&lt;/option&gt; &lt;option value="d12"&gt;d12&lt;/option&gt; &lt;/select&gt; &lt;input class="value-main1" type="text" name="attr_duty_statement"&gt; &nbsp;&nbsp;&nbsp;&nbsp;... &lt;/div&gt; CSS: .sheet-growth-container { display:grid; position: relative; left: 22px; background: white; width: 80px; padding: 10px; } .sheet-growth-header { grid-column: 1 / span 2; background: #3a7a6b; color: white; font-weight: bold; font-size: 14px; padding-left: 5px; } .sheet-growth-menu { background: #e6e6e6; font-weight:bold; height: 30px; padding-left: 5px; padding-right: 5px; } /*Growth Section ends here*/ .sheet-plot-container { display: grid; position: relative; left: 122px; top: -190px; background: white; width: 155px; padding: 10px; } .sheet-plot-header { background: #ebd647; color: white; font-weight: bold; font-size: 14px; padding-left: 5px; margin-left: 10px; } .sheet-plot-main { grid-column: 2 /span 1; font-size: 27px; text-align: center; margin-left: 30px; margin-bottom: 5px; margin-top: 5px; } /*Plot Points and Complications ends here*/ .sheet-dice-header { grid-column: 2 / span 1; font-weight: bold; background: orange; color: white; padding-left: 10px; margin-left: 10px; } .sheet-dice-main { min-width: 120px; max-width: 120px; min-height: 72px; max-height: 72px; margin-left: 10px; } /*dice Section ends here*/ div.sheet-value-container { display:grid; background: white; position: relative; top: -205px; width: 770px; padding: 10px; } h4.sheet-value-header { grid-column: 2 / span 4; background: #042254; color: white; font-weight: bold; font-size: 14px; padding-left: 5px; margin-left: 8px; } .sheet-value-header1 { background: #e6e6e6; font-weight:bold; padding-left: 5px; padding-right: 5px; } .sheet-value-header2 { background: #bfbfbf; margin-left: 8px; } .sheet-value-menu { background: #e6e6e6; font-weight: bold; padding-left: 10px; padding-right: 5px; margin-left: 8px; } .sheet-value-main { width: 60px; margin-left: 5px; } .sheet-value-main1 { width: 545px; } /*Values Section ends here*/ I apologise if this is way too much information, but it seems to be quite a broad issue. If people can't help me the quick fix would be to extend the first box by a large amount that a player feasibly won't reach, but I'm kind of curious as to why it's only some elements in this box being affected. Thank you
1605626370

Edited 1605626825
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I think (emphasis on the think) that what is happening here is you are specifying a position (relative) and offset (top and left) for your growth and plot containers. However, you have not specified a position for box2, so it is positioning these containers in relation to their position in the container holding box2 that has a position defined; this can go all the way to the browser window/whole page if there is nothing with a position defined before that. Give box2 position:relative and it should fix the issue. Really though, I'd highly recommend not using position and offsets to place these. Just make a grid in box2 and place each of those divs (and the repeating sections after them) in a specific grid area. Edit: and just saw your entire css. So, I believe the issue is your use of position:static on box2. It's probably having a similar effect to what I was proposing about not having position defined.. If you want to make these columns adjacent to each other, then I would really recommend using a different method, like css grid, to place box1 and box2.
Thanks Scott. The problem still persists when I set the field to :relative. The code I put over has it in static just to I can flick back between the vertical and horizontal alignments as the preview window doesn't fit or allow you to scroll left or right Thank you for the suggestion of using grids. I had been avoiding it up to now on the larger scale segments just because when I tried it last it looked like you had to make an individual cell for each element in a row and I didn't want to do that. If there's a simpler way to do it though, please do let me know. I think I've see other ways by like assigning a style to a class type and then writing that in a grid format instead of wollumn widths, but I couldn't wrap my head around it.
1605636524
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Making complex overlapping layouts with grid is a bit of a pain, but you can do it. If you aren't doing an overlapping layout then it's actually pretty easy. In whatever div you have that contains box1 and box2, you could just do: .sheet-main-container{ display:grid; grid-template-rows:1fr 1fr; grid-template-columns:auto; grid-template-areas: "box1 box2"; place-items:start / stretch;/*This sets it so that box1 and box 2 will only take up as much vertical space as they need, but will stretch to fill the grid cell horizontally*/ } .sheet-box1{ grid-area:box1; } .sheet-box2{ grid-area:box2; }
This absolutely did the trick! thank you very much for that advice. I may vace a god at applying that to the rest of my sheet to make it a bit cleaner!