I am trying to align the baseline of some text in a div
to the very bottom edge of said div
(such that characters like g
and j
would actually overflow the div)
I can only seem to align the bottom edge of the text element to the bottom edge of the div
.
I have tried to use vertical-align
with values baseline
and bottom
on the inner and outer element, but without success.
div {
height: 80px;
width: 300px;
background: #ff5;
position: relative;
}
span {
font-size: 30px;
position: absolute;
left: 0;
bottom: 0;
}
<div>
<span>
TEST gjp ABC
</span>
</div>
I also want to be able to offset the baseline from the bottom of the div (e.g. bottom: 10px;
positions the baseline of the text 10px from the bottom edge of the div).
Edit: I should also mention that I want to keep the position: absolute;
property on the span
element, because I want to freely position multiple of those in the parent div.
For example, here, A's baseline should be at the bottom edge of the div, B's should be 10px above it and C's 20px:
div {
height: 80px;
width: 300px;
background: #ff5;
position: relative;
}
span {
font-size: 30px;
position: absolute;
left: 0;
bottom: 0;
}
<div>
<span style="left: 0px; bottom: 0px;">
A
</span>
<span style="left: 50px; bottom: 10px;">
B
</span>
<span style="left: 100px; bottom: 20px;">
C
</span>
</div>
position:absolute;
in thespan
because I want to freely position multiple of thosespan
elements in the parent div. I didn't state this explicitly in my original question, so I'll edit it – Tailored