Josh Correia
Josh Correia

Reputation: 4346

Adding text to div moves text upward

I am attempting to add text to my div but whenever I add text it moves some of the text upward off of the screen. I have to adjust the margin-top every time that I add text to the div to correct this. Is there any way to make the text only expand downward when I add text so I don't need to keep adjusting the margin-top?

https://jsfiddle.net/2ey21qj5/4/

div.test {
    margin-top:0cm;
    text-align:center;
    position: absolute;
    left:50%;
    transform:translate(-50%,-50%);
    background: grey;
    top: 5cm;
}

Upvotes: 0

Views: 125

Answers (1)

P.S.
P.S.

Reputation: 16384

Just remove transform: translate(-50%,-50%); and position your text as you want. Or give it 0 arguments: transform: translate(0,0);

Upvotes: 1

Related Questions