I need to center vertically a form with fields (input/select) inside a search container. The layout is intented to be 100% width and 100% height.
I try to center the form using fluid paddings but it's pushing everything down:
html,
body {
height: 100%;
overflow: hidden;
}
.main-ctn {
width: 100%;
height: 100%;
background-color: #808080;
}
.search-ctn {
width: 100%;
height: 3.703703704%;
background-color: #fff;
float: left;
padding-top: 2.314814815%;
padding-bottom: 2.314814815%;
}
.map-ctn {
width: 85%;
height: 88.42592593%;
background-color: #0094ff;
float: left;
}
.result-list-ctn {
width: 15%;
height: 88.42592593%;
background-color: #ffd800;
float: right;
}
.footer-ctn {
width: 100%;
height: 1.388888889%;
background-color: #ff6a00;
float: left;
padding-top: 0.925925926%;
padding-bottom: 0.925925926%;
}
.map-canvas {
height: 100%;
margin: 0px;
padding: 0px;
}
.map-canvas img {
max-width: none; /* we need to overide the img { max-width: 100%; } to display the controls correctly */
}
Main View:
<body>
<div class="main-ctn">
<div class="search-ctn">
<!-- Search form -->
@{ Html.RenderAction(MVC.Partner.Search()); }
</div>
<div class="map-ctn">
<!-- Map container -->
@{ Html.RenderAction(MVC.Map.Index()); }
</div>
<div class="result-list-ctn"></div>
<div class="footer-ctn"></div>
</div>
</body>
</html>
Map View:
<div id="map-canvas" class="map-canvas"></div>
The problem is from the reset.css file:
*,
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
and the to set th height of the page to 100%:
html,
body {
height: 100%;
overflow: hidden;
}
Script to build the map:
// Private variables
var _map;
var _mapCanvas = "map-canvas";
var _initialCenterLat = "39.843077"; // Center of Portugal
var _initialCenterLng = "-7.992554";
var _initialZoom = 7;
build = function () {
var mapOptions = {
center: new google.maps.LatLng(_initialCenterLat, _initialCenterLng),
zoom: _initialZoom
};
_map = new google.maps.Map(document.getElementById(_mapCanvas), mapOptions);
};