Skip to content

Instantly share code, notes, and snippets.

@CarmenScholte
Last active October 8, 2019 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CarmenScholte/aa621fe146cb27baa41a10788ae2d9aa to your computer and use it in GitHub Desktop.
Save CarmenScholte/aa621fe146cb27baa41a10788ae2d9aa to your computer and use it in GitHub Desktop.
Fullscreen fixed image header
<!doctype html>
<html lang="en">
<head>
<base href="/">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
html {
height: 100%;
}
body {
margin: 0;
}
.header {
height: calc(100vh - 56px);
}
.background {
width: 100%;
}
.background-gradient {
position: absolute;
height: calc(100vh - 56px);
width: 100%;
top: 0;
left: 0;
background: linear-gradient(to top, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0) 33%);
}
.background-image {
position: fixed;
min-width: 100%;
min-height: 100%;
width: 1%;
height: 1%;
object-fit: cover;
z-index: -1;
}
.branding {
position: absolute;
bottom: 0;
left: 0;
right: 0;
margin-bottom: 200px;
color: white;
}
.navigation {
position: sticky;
top: 0;
z-index: 2;
background: white;
}
.nav-item {
padding: 16px;
}
.content-placeholder {
height: 2000px;
background-color: white;
}
</style>
</head>
<body>
<div class="header">
<div class="background">
<img class="background-image"
src="https://images.unsplash.com/photo-1508873699372-7aeab60b44ab?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=3300&q=80" />
<div class="background-gradient"> </div>
</div>
<div class="branding">
<div class="container">
<div class="logo">LOGO</div>
<h1 class="title">Title</h1>
<h2 class="subtitle">Subtitle</h2>
</div>
</div>
</div>
<div class="navigation">
<div class="container">
<div class="row">
<div class="nav-item">
Education
</div>
<div class="nav-item">
Research
</div>
<div class="nav-item">
Contact
</div>
</div>
</div>
</div>
<div class="content-placeholder"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment