Skip to content

Instantly share code, notes, and snippets.

@giangmd
Last active December 18, 2019 09:32
Show Gist options
  • Save giangmd/81ee1d50e114f7da7496604dc81584ec to your computer and use it in GitHub Desktop.
Save giangmd/81ee1d50e114f7da7496604dc81584ec to your computer and use it in GitHub Desktop.
Css Parallax Background Image
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>CSS Parallax Background Image</title>
<style>
html, body, div {
height: 100%;
margin: 0;
}
.parallax {
position: relative;
}
.bg {
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
height: 100%;
display: flex;
justify-content: flex-end;
align-items: center;
position: relative;
background-image: url('http://giangmd.net/wp-content/uploads/2019/12/eagle.jpg');
}
.content {
max-width: 600px;
min-height: 5000px;
color: #fff;
margin: auto;
border: 4px solid red;
}
</style>
</head>
<body>
<section class="parallax">
<div class="bg">
<div class="content">
Exercitation veniam ut et voluptate exercitation quis qui consequat cupidatat nisi sint sed in excepteur dolor labore in enim laboris culpa nostrud quis sed in.
</div>
</div>
</section>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment