html - CSS - Spacing shows up when switching to different screen sizes -


i have css issue, spacing shows when being under different screen size. please have @ picture below understand better.

<div id="map" style="width: 100%; height:70%"></div>  <div class="subtitle">subtitle here</div>      <div class="details">   <ion-grid class="borderbottom" no-padding>     <ion-row padding>          </ion-row>   </ion-grid>   <ion-row>     <button ion-button full color="light"></button>   </ion-row> </div> 

css

 .subtitle{  padding: 4px 0 5px 0; font-size: 4.7vw; background-color: #22a800; width: 100%; text-align: center; color: white; font-weight: 600;  }    .details{  width: 100%; bottom:0; background: white; text-align: center; box-shadow: 0px -5px 5px rgba(0, 0, 0, 0.1);  border-top:1px solid #dedede;  width:100%;  position: fixed; background: #f9f9f9;   } 

normal

enter image description here

when switched screen size, issue appears:

enter image description here

i doubting issue on following line:

   <div id="map" style="width: 100%; height:70%"></div> 

where height set 70%, green bar on other screen sizes goes below "some info in box"

the thing is... it's still 70%, original 70% set based on first screen - , 'magic number' worked... you've found - doesn't work when screen larger or smaller.

you may need use flex-box here - or javascript check browser height , make decisions based on element sizes.

https://jsfiddle.net/sheriffderek/xws3e18z/

<div class="map">   map </div>  <div class="sub-title">   sub-title </div>  <div class="other-stuff">   other-stuff </div>  <div class="button">   button </div> 

...

html {   height: 100%; }  body {   height: 100%;   display: flex;   flex-direction: column; }  div {   padding: 1rem; }  .map {   background: gray;   flex-grow: 1; }  .sub-title {   background: lightgreen; }  .other-stuff {   background: white;   flex-basis: 100px; }  .button {   background: lightgray; } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -