I added a landing page to my webapp, so when it is loading data from the server, the landing page is shown with a loading image and a description.
<div class="map_view">
<!-- shown only when data is not available -->
<div class="loading_screen">
<img src="/img/loading_boys.gif"/>
<h2>Connecting to the the network ...</h2>
</div>;
</div>
The div loading screen
is on top of div map_view
. I want to center the image and the <h2>
on its parent div. I can use text-align: center;
to center it horizontally. But I cannot find a way to center it vertically. I want to make it compatible to different screen sizes as well, so no matter in what devices, the loading div is always in the center of its parent div.
I tried to use display: table;
in map_view
and display: table-cell; vertical-align: middle;
on loading_screen
, but then the google map disappears, with just a background color.
. But the
– J Freebird Jan 04 '16 at 01:21content was pushed to the right of the image, I want it to be behind the image. It also caused the image to be stretched horizontally. Deleting the
solves all of the above. I wonder how to fix it in another way?