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 .
×
May your rolls be chill this holiday season!
Create a free account

Centering Questions

1586125502

Edited 1586125627
Does anyone know the answers to these questions? Is it possible to vertically center text <div>in a div</div>, and if so how? Is it possible to vertically center text <span>in a span</span>, and if so how? Is it possible to horizontally center text <select>in a select</select>, and if so how?
1586126531

Edited 1586126670
Andreas J.
Forum Champion
Sheet Author
Translator
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/text-align" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/CSS/text-align</a> The sheet mentioned in the other thread uses it in a couple of places
1586131070

Edited 1586131194
I think fixing the issues I'm seeing may be more about finding the syntax error rather than finding the right attribute. Here's the first spot of code I'm working with, where the text "Game Title" is not vertically centered, despite having the&nbsp; vertical-align: text-top; &nbsp;attribute applied: &lt;div class="menu"&gt; &lt;div class="mtv gameTitleBackgroundColor section"&gt; &lt;div class="gameTitle section"&gt;Game Title&lt;/div&gt; &lt;/div&gt; ------------------------------------------------ .sheet-menu { display: grid; width: 800px; /*ideal 800*/ height: 97px; /*ideal 600*/ grid-gap: 0px; grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr; grid-template-rows: 39px 39px 19px; grid-template-areas: "mtv mtv mtv mtv pla pla nme nme nme nme nme sex sex spc spc spc spc lvl" "scl scl scl scl ord ord orv eth eth etv age wgt hgt exp exp nlv nlv cpt" "mnu mnu mnu mnu mnu mnu mnu mnu mnu mnu mnu mnu mnu mnu mnu mnu mnu mnu"; } .sheet-mtv { &nbsp;&nbsp;&nbsp;&nbsp;grid-area: mtv; } .sheet-gameTitleBackgroundColor { background-color: #1E90FF; border: 2px solid #4169E1; } .sheet-gameTitle { font-size: 33px !important; text-align: center; vertical-align: text-top; color: white; } For both of the vertical alignment questions, I've also tried vertical-align-(baseline, top, middle, bottom, sub, and with !important. Here's the second spot of code I'm working with, where the text &lt;span&gt;in the span&lt;/span&gt; is not vertically centered, despite having the&nbsp; vertical-align: text-top; &nbsp;attribute applied: &nbsp;&nbsp;&nbsp;&nbsp;&lt;div class="dm backgroundColor section"&gt; &nbsp;&nbsp;&nbsp;&nbsp; &lt;div class="fieldLabel section"&gt;Melee Dmg.&lt;/div&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input name="attr_melee_damage_bonus" type="hidden" value="0"&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;span class="field derived" name="attr_melee_damage_bonus"&gt;&lt;/span&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt; ------------------------------------------------- .sheet-coreStats { display: grid; width: 450px; /*ideal 800*/ height: 350px; /*ideal 600*/ grid-gap: 0px; grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr; grid-template-rows: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr; grid-template-areas: "ps ps pss pss pss dm dm dm en en en en mw mw mw psl psl" "pe pe pes pes pes la la ra ra ra ft ft ft hl hl pel pel" "ag ag ags ags ags ia ia oa oa oa da da da ap ap agl agl" "ob ob obs obs obs hd hd sc sc st st in in il il obl obl" "ms ms mss mss mss cp cp cp mc mc mc mc ls ls ls msl msl" "me me mes mes mes mr mr mr mr mr ci ci ci ci ci mel mel" "pr pr prs prs prs lm lm lm ns ns ns ns nf nf nf prl prl" "mt mt mts mts mts md md md ma ma ma ma ad ad ad mtl mtl" "mp mp mps mps mps pl pl pl pl pl mm mm mm mm mm mpl mpl"; } .sheet-dm { &nbsp;&nbsp;&nbsp;&nbsp;grid-area: dm; } .sheet-backgroundColor { background-color: #4169E1; } .sheet-fieldLabel { font-size: 12px !important; font:caption; text-align: center; color: white; } .sheet-field { border: 1px solid #4169E1; border-radius: 0px; margin: 0px 0px; width: 100% !important; } .sheet-derived { &nbsp;&nbsp;&nbsp;&nbsp;display: inline-block; font-size: 12px !important; height: 23px !important; text-align: center; vertical-align: text-top; &nbsp;&nbsp;&nbsp;&nbsp;background-color: white; } Here's the last spot of code I'm working with, where the text &lt;option&gt;in the select option&lt;/option&gt; is not horizontally centered, despite having the&nbsp; text-align: center; &nbsp;attribute applied: &nbsp;&nbsp;&nbsp;&nbsp;&lt;div class="spc backgroundColor section"&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class="fieldLabel section"&gt;Species&lt;/div&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;select name="species" class="dropDown"&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value="1"&gt;1&lt;/option&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value="2"&gt;2&lt;/option&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;option value="3"&gt;3&lt;/option&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/select&gt; &nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt; ------------------------------------------------------- .sheet-backgroundColor { background-color: #4169E1; } .sheet-fieldLabel { font-size: 12px !important; font:caption; text-align: center; color: white; } .sheet-dropDown { height: 25px !important; width: 100% !important; border: 1px solid #4169E1; border-radius: 0px; } I've looked over the web for the answers to these questions.&nbsp; That's why I allow for the possibility that the answer to whether this can be done is no.&nbsp; I just thought that someone else might have found a solution. That said, it's also possible that the reason it's not working is a syntax error.
I generally use flex for my alignment issues: &lt;div class="container"&gt; &lt;div&gt;Thingie&lt;/div&gt; &lt;/div&gt; .container { display: flex; height: 50px; align-items: center; } I'm not as familiar with grid, but it also has an align-items you can try:&nbsp; <a href="https://css-tricks.com/snippets/css/complete-guide-grid/#prop-align-items" rel="nofollow">https://css-tricks.com/snippets/css/complete-guide-grid/#prop-align-items</a>
1586135550

Edited 1586135596
I hadn't considered that, but I think you're right Zed.&nbsp; I think, at least the vertical alignment issues, are related to my limited understanding of CSS grid, which for the moment at least, seems like a rabbit hole. Grid is still totally worth it though = ) ! The horizontal alignment issue though, I think is unrelated to CSS grid.&nbsp; The text orientation is in reference to the drop down menu frame, rather than the grid itself.