make text vertical center in div code example
Example 1: css align items vertical center
.parent {
display: flex;
justify-content: center;
align-items: center;
}
Example 2: css vertical center
/* No Flexbox */
.parent {
position: relative;
}
.child {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
/* With Flexbox */
.parent {
display: flex;
flex-direction: column;
justify-content: center;
}
Example 3: css center text in div vertically
<!DOCTYPE html>
<html>
<head>
...
<style type="text/css">
div{
width: 200px;
height: 200px;
border: solid green;
display: table-cell;
vertical-align: middle;
}
</style>
</head>
<body>
<div>Vertikal ausgerichteter Text</div>
</body>
</html>