title: Text not centered on image
body: <p>I am displaying a map for user's location and then showing a message on top of the map. I want to dynamically size the map (mapWidth &amp; mapHeight) based on the user's device &amp; window size and position the text in the center. </p>
  
  <p>I'm using 50% top/left positioning, but often the text is not center positioned. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var ip = '1.2.3.4';
  var msg = 'Welcome User';
  
  var mapUrl = 'https://maps.googleapis.com/maps/api/staticmap?center=';
  var mapWidth = 250;
  var mapHeight = 150;
  var mapParams = '&amp;zoom=9&amp;size='+mapWidth+'x'+mapHeight+'&amp;scale=1';
  
  var locationUrl = 'https://ipapi.co/';
  var locationField = '/latlong/';
  
  var updateMap = function(data){
      $('.map-img').attr('src', mapUrl + data + mapParams);
      $('.ip').text(msg).fadeIn('slow');
  };
  
  $.get(locationUrl + ip + locationField, updateMap);</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.ip {
    position: absolute;
    top: 50%;
    left: 50%;
    display: none;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;div style="position:relative;"&gt;
      &lt;img class="map-img" src=""&gt;
      &lt;div class="ip"&gt;&lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>