CSS - Align div in bottom of screen without using position: absolute

1k Views Asked by At

I'm designing a PhoneJS app, and I need to have a button placed in the bottom of the screen, but without using position: absolute.

Why don't I just use absolute?

As this is a PhoneJS application, this causes problems when flipping the phone to landscape (refer below)

This is portrait (button placed correctly)

enter image description here

This is landscape (button misplaced)

enter image description here

How can one accomplish such task without using the position: absolute css attribute?

3

There are 3 best solutions below

3
Guy On BEST ANSWER

You will still have the issue of two buttons and no space regardless of position: absolute.

I would suggest using a media query to target landscape and change the styles.

/* iPhone Landscape */
@media only screen 
  and (min-device-width: 320px) 
  and (max-device-width: 480px)
  and (-webkit-min-device-pixel-ratio: 2)
  and (orientation: landscape) {

  /* Styles go here */

}

Media queries on CSS Tricks

0
rico On

try to use the @media tags for css in this code.

0
Ram kumar On

You can use table method like this in example. http://jsfiddle.net/2232cyrq/

make height:100% for body and html and main wrapper will stand as display: table and table-cell for bottom content