html - Get rid of whitespace on top of the text in div -


div bounding box

here bounding box of div tag shown chrome dev tools. both font-size , line-height set 100px. margin , padding properties set 0. div element absolutely positioned on webpage.

how make text start right top of bounding box? need rid of white-space on top of "s" character.

if that's impossible rid of white space, there way calculate height?

here fiddle showing problem: https://jsfiddle.net/zw4g1uuj/

i noticed while taking @ jsfiddle line height might primary factor why you're seeing whitespace. @ font-size 100, bounding box of div fit text, , centered lineheight 100. issue when have div unbounded height (and in case text box sized to), you're adding yet factor size of div (lineheight) causes white space appear @ top when dont want it. decreasing lineheight, lets 80 in jsfiddle, make top white space decrease.

if made div bounded maybe fixed height of 120, lineheighted 120, text center, have spacing on both top , bottom. decreasing fixed size of box closer size of font , adjusting lineheight can squeeze more whitespace out of it.

this 1 of more finicky pieces of css work around. i've had trouble predicting lineheight behavior best experiment this. css code parent containers or how designed element in question interfere it.

not that, font can add whitespace because not inherently wrong css, font has few more pixels @ top @ bottom.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -