Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Centering an element with css
<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<title>Position Center</title>
border:20px solid rgba(0,0,0,.5);
width: 400px;
height: 200px;
background: yellow;
position: fixed;
top: 50%;
left: 50%;
margin-top: -140px;
margin-left: -240px;
text-align: center;
display: table;
display: table-cell;
text-align: center;
vertical-align: middle;
border:50px solid rgba(0,0,0,.2);
<h2><a href=""></a></h2>
<div class="container">
<div class="box">
<form action="">
<input type="text" name="" id=""><br>
<input type="submit" value="Search">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.