I cut all unrelated parts of my page out to narrow down the problem.
When the page initially loads, the title is the correct size, but when the map loads, it changes the size of the title. If I comment out the map div, the title remains the correct size.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link href="stylesheet.css" rel="stylesheet">
</head>
<body>
<div id="navbar">
<h2>Title</h2>
</div>
<div class="mainContent">
<div id="map"></div>
</div>
</body>
<script src="map.js"></script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=MYKEY&callback=initMap"></script>
</html>
map.js
var map = null;
function initMap() {
var location = {lat: 37.421842, lng: -122.084119};
map = new google.maps.Map(document.getElementById('map'), {
zoom: 17,
center: location
});
}
stylesheet.css
#map {
height: 350px;
width: 100%;
}
body {
font-family: 'Roboto', sans-serif;
}
#navbar {
background-color: gray;
}
.mainContent {
margin: 20px;
}
I tried setting the size of everything manually but it seems to override everything, including !important. The only thing that fixes is it not using Roboto font.