How to set % height in fluid layout?


Tags: iphone,html,css,css3,responsive-design

Problem :

I am designing fluid layout pages (defining everything in % in CSS) for multiple devices (desktop/tablet/mobile)

Now while I do understand that giving width:100% takes the entire viewport available width (i.e. available browser area) and accordingly calculates all the % widths ?

But my question is how do I set or convert any "pixel" height to % height for defining fluid layouts CSS?



Solution :

You have to give your body styles like so...

 body {width: 100%; height: 100%; min-height: 100%; height: auto;}

As your body has a height of the viewport, anything that is a child of it can be specified using percentage, like a div 50% of the screen would be...

body div {height: 50%; min-height: 50%; height: auto;}

Remember % is inherited from its parent.


    CSS Howto..

    How to preform whitelist-based CSS filtering in PHP

    How to avoid text wrap when the parent element has position absolute?

    How to draw a line with css and show text or image on it

    How to prevent transition to run on page load after height is set with javascript in Safari?

    How can I add pagination to my site's gallery?

    How to dynamically insert css vendor prefixes using jquery

    How do I code a BTN in an HTML project to open a users email client

    Normalize.css how to use it?

    Force jQuery show/hide to respect display: table?

    How to add strped tabs on Ionic css

    how to include css and js files to php template?

    How to make a new class

    jQuery-Based Dropdown Shows Gap Outside of Firefox

    How to make the width of parent div equal to the width of child image, and height of child image to height of the parent div using CSS only

    How can I make a drop down menu without changing the width of the main menu item?

    How to add JS to Wordpress and reference CSS or other scripts?

    How to create a dotted shadowy effect on an image with CSS?

    How do i vertically align my form in bootstrap?

    How to insert instance variable as css rule in Rails?

    How to change the position of the JQuery dialog box

    How to change Kendo Excel Button Content Text

    How to use center-block and vertical align together using Bootstrap?

    How to remove the extra space between two span elements?

    Using Bootstrap, how do i achieve this horizontal tab layout? [closed]

    CSS - How to break long words in a table td?

    Button element styled with CSS is not showing the background-image in IE6

    How to create a box with rounded corners at the top, but normal corners at the bottom?

    Meteor: How can I use Spacebars to apply different CSS elements?

    How to make a text slideshow using CSS/HTML/JAVA

    How do I fix the navigation menu in Firefox and Internet Explorer?