Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Css percents

Featured Replies

hello!

 

Im trying to create a liquid layout...

 

I want to have the top of the page at 90% of the window and the footer 10%, I thought this would work...

 

#container
{
width: 100%;
height: 100%;
margin: 10px auto;
background-color: #fff;
color: #333;
}


#content
{
width: 100%;
height: 90%;
border: 1px solid gray;
}

#footer
{
width: 100%;
height: 10%;
border: 1px solid gray;
}

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<link href="master.css" rel="stylesheet" type="text/css">
</head>

<body>
<div id="container">
<div id="content">content</div>
<div id="footer">footer</div>
</div>
</body>
</html>

 

 

But I only get the height of the text? Can any one suggest any tips?

 

Thanks Ben

  • Author

Thanks TT works great!

 

#container

{

width: 100%;

height: 100%;

background-color: #fff;

color: #333;

position: absolute;

}

 

cool! Never attempted a liquid layout before any tips?

Only one tip:

- use max-width and min-width so the page won't be too narrow or too wide

Whats a Liquid Layout?

A liquid design is one, like Wikipedia, where the design moves to flow content into the whole screen, or a portion of the screen, no matter what the size of the browser window. Proponents of liquid design prefer to use all the screen space available. Liquid design can be achieved through the use of CSS, by avoiding styling the page altogether, or by using HTML tables (or more semantic divs) set to a percentage of the page.

 

http://en.wikipedia.org/wiki/Web_design#Li...s_fixed_layouts

  • Author

Know Im trying to float 2 divs in the content div, Ive set them to 50% each so they should sit in there? (leftcontent & rightcontent), Ive even tried a clear: both; on the content div but with no luck? The rightcontent div sits uneath the leftcontent div?

 

<div id="container">
<div id="content">
<div id="leftcontent">left</div>
<div id="rightcontent">right</div>
</div>
<div id="footer">footer</div>
</div>

 

#container
{
width: 100%;
height: 100%;
background-color: #fff;
color: #333;
position: absolute;
}


#content
{
width: 100%;
height: 90%;
border: 1px solid gray;
clear: both;
}

#leftcontent
{
width: 50%;
height: 90%;
border: 1px solid gray;
float: left;


}

#rightcontent
{
width: 50%;
height: 90%;
border: 1px solid gray;
float: left;
}

#footer
{
width: 100%;
height: 10%;
border: 1px solid gray;

}

You haven't took into account the border which is added to the 50% rather than being part of it so really you have 1px on the left +50% + 1px on the right .

 

 

So there isn't enough space for them to both be on the same line as together as it totals 100% and 4px.

try to reset all margins and paddings

 

* {
padding:0;
margin:0;
}

 

if that won't work try to change

width:50%

 

to

 

width:49%

 

[edit] right.. I didin't saw the borders. just change the the width.

  • Author

School Boy error! Thanks, Should have noticed that!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.