html - Align the capline (top of text) with different size fonts -
i have set of numbered subsections on web page, each of has associated title in line section's ordinal (number). it's ordered list each item contains arbitrary content.
the design calls (a) ordinal of each section approximately twice tall title text, (b) capline (top) of title (rendered fullcaps) aligned capline of ordinal.
the title text dynamic, , may take anywhere 1-4 "lines" depending on length.
i've tried using vertical-align:top within elements formatted using table-cell, , close desired look:
.title_line { display: table; } .title_line .ordinal { display: table-cell; vertical-align: top; font-size: 4em; } .title_line .title { display: table-cell; vertical-align: top; font-size: 2em; text-transform: uppercase; } <body> <div class="title_line"> <div class="ordinal">3</div> <div class="title">the capline (top) of text should aligned top of ordinal.</div> </div> </body> but there visible difference in vertical gap above ordinal compared title text.
is there way specify capline alignment text of different size?
this can fixed setting line-height of 1em.
.title_line { display: table; } .title_line .ordinal { vertical-align: top; display: table-cell; line-height: 1em; font-size: 4em; } .title_line .title { display: table-cell; vertical-align: top; font-size: 2em; text-transform: uppercase; } <body> <div class="title_line"> <div class="ordinal">3</div> <div class="title">the capline (top) of text should aligned top of ordinal.</div> </div> </body> this removes space between actual font , how rendered. if add outline or background .ordinal, can see how works:
span { vertical-align: top; font-size: 4em; outline: 1px solid red; } .fix { line-height: 1em; } <span>3</span> <span class="fix">3</span> 
Comments
Post a Comment