Skip to content

Instantly share code, notes, and snippets.

@marifrahman
Created January 10, 2014 06:30
Show Gist options
  • Save marifrahman/8347805 to your computer and use it in GitHub Desktop.
Save marifrahman/8347805 to your computer and use it in GitHub Desktop.
body {
background-image: url('http://lorempixel.com/output/technics-q-c-1244-1096-2.jpg');
background-repeat: no-repeat;
background-size: cover;
text-align:center;
}
#maindiv {
width:900px;
height:500px;
margin-left: auto;
margin-right: auto;
margin-top: 140px;
background-color:#404853;
}
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Center align a div with background image" />
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div id="maindiv" class="rounded">
something written
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment