Last active
December 18, 2019 09:32
-
-
Save giangmd/81ee1d50e114f7da7496604dc81584ec to your computer and use it in GitHub Desktop.
Css Parallax Background Image
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> | |
<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