0

I could probably do this in PHP, but I would have to include the CSS into my PHP file. So, I have a parent div whose height always varies, and then I have a child div whose width: 100%; height: 100%; in that child div, I have text. The problem is, I want to vertically center the text inside the ChildChild div.

#parentDiv {
width: 200px;
height: PHP generates this;
}
#Child {
width: 100%;
height: 100%;
}
#ChildChild {
margin: how do I do this?
}

<div id="ParentDiv">
<div id="Child">
<div id="ChildChild">
HELLO!
</div>
</div>
</div>

1 Answer 1

1

If your text is only going to be one line high, try setting line-height: 100%;. Otherwise, maybe try following the solution outlined here, which involves using the display: table-cell; property to allow the desired use of the vertical-align: middle; property.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.