SolutionCottage.com
Posted  04 May 2009 - 20:05:23

Category: CSS


Center a line of text in a div

Issue:
You want to center a line of text in a div. Sounds simple, but can be tricky to do.

Solution:

Here is the example HTML:

<div class="container">
<p class="title">This is a title</p>
</div>

And the CSS:
.title
{
color: White;
}

.container {
min-width: 10em;
min-height: 10em;
display: table-cell;
vertical-align: middle;
background-color: Blue;
text-align: center;
}


Example:

This is a title








0 comments:








© SolutionCottage 2008-2011 9/24/2017 1:10:32 PM