css vertical align center text code example
Example 1: css align items vertical center
.parent {
display: flex;
justify-content: center;
align-items: center;
}
Example 2: css align text vertically
<div class="text">
lorem ipsum
</div>
.text {
vertical-align: middle;
}
Example 3: text vertical align css
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style type="text/css">
div {
display: table-cell;
width: 250px;
height: 200px;
vertical-align: middle;
}
</style>
</head>
<body>
<div>Vertically aligned text</div>
</body>
</html>
Example 4: vertical align css
.container{
display: table;
}
.div-inside-container{
display: table-cell;
vertical-align: middle;
}
Example 5: css center div
<!--
Simple CSS CENTER DIV Example
* See Fiddle in link for PoC *
-->
<div class="parent">
<div class="child">
<p>
Eh Up Me Duck!
</p>
</div>
</div>
<style>
.parent {
border: 1px solid black;
padding: 2px;
}
.child {
border: 1px solid red;
width: 50%;
margin-left: auto;
margin-right: auto;
}
p {
text-align: center;
}
</style>