Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Centering an element with css
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Position Center</title>
<style>
.container{
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;
padding:40px;
display: table;
}
.box{
background:orange;
display: table-cell;
text-align: center;
vertical-align: middle;
border:50px solid rgba(0,0,0,.2);
}
</style>
</head>
<body>
<h2><a href="http://www.tutorial-webdesign.com">Tutorial-webdesign.com</a></h2>
<div class="container">
<div class="box">
<b>Goooogle</b>
<form action="">
<input type="text" name="" id=""><br>
<input type="submit" value="Search">
</form>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment