HTML Compiler Online
Javascript Online Compiler
index.html
Change Theme
Compress code
Format code
Download Code
Clear Code
Copy Code!
RunĀ
ctrl+s or click
Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Article - center vertically using position absolute</title> <style> /* Center vertically */ .parent { display: flex; align-items: center; border: 2px solid #4B5681; background: #7E89B4; height: 200px; } .child { height: 100px; width: 200px; background: #353C5A; font-family: sans-serif; color: white; } </style> </head> <body> <h2>To align a element to the center vertically use CSS flexbox with align-items: center</h2> <br> <div class="parent"> <div class="child">Child</div> </div> </body> </html>
RunĀ