Skip to content

Instantly share code, notes, and snippets.

@tristen
Created April 28, 2016 19:17
Show Gist options
  • Save tristen/768ac555d78b7b7123791580b2f21b90 to your computer and use it in GitHub Desktop.
Save tristen/768ac555d78b7b7123791580b2f21b90 to your computer and use it in GitHub Desktop.
Full screen map with fixed header
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.17.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.17.0/mapbox-gl.css' rel='stylesheet' />
<link href='https://www.mapbox.com/base/latest/base.css' rel='stylesheet' />
<link href='site.css' rel='stylesheet' />
</head>
<body>
<header class='col12 contain z1 fill-blue dark'>
<div class='pad1'>
<h4>Heading title</h4>
</div>
</header>
<div id='map' class='map'></div>
<script>
mapboxgl.accessToken = 'pk.eyJ1IjoidHJpc3RlbiIsImEiOiJiUzBYOEJzIn0.VyXs9qNWgTfABLzSI3YcrQ';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v8',
center: [-74.50, 40],
zoom: 9
});
</script>
</body>
</html>
.map {
position:absolute;
width:100%;
top:40px; /* The height of the header */
bottom:0;
left:0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment