Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Der Titel des Dokuments</title> <style> .parent { position: relative; width: 100%; height: 220px; background: #1faadb; color: #fff; } .child_1, .child_2 { position: absolute; top: 50%; left: 50%; width: 90px; height: 90px; padding: 5px; background: #8ebf42; text-align: center; } .child_1 { transform: translate(-50%, -50%); } </style> </head> <body> <div class="parent"> <div class="child_1">Vertikal zentrierter Text</div> </div> </br> <div class="parent"> <div class="child_2">Nicht zentrierter Text</div> </div> </body> </html>