Created
January 26, 2013 16:20
-
-
Save tutweb/4643102 to your computer and use it in GitHub Desktop.
Centering an element with css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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