954,168 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Div percentage height, centered and scrolling... or not...

Hello, I have a problem. I want a div element to be 90% the width of a cell in a table and 80% the height. The width bit works, but height doesnt.
I also want it to be centered in the cell. Doesnt work.
I also want there to be a verticle scrollbar when necessary.

so far i have:

#content {
height: 80%;
width : 90%;
margin-left: auto;
margin-right: auto;
padding: 5px;
text-align: center;
overflow: auto;
}

and I have set the html and body to have a 100% width and height.

The div scrolls in IE, but in firefox it expands downwards.
in firefox it is centered, but in IE it is not.
in firefox the height is auto (rather than 80%).

see http://www.nugit.co.uk/?dirr=1Home%2F1Products%2F1DVD+Players%2F2Portable


Thanks in advance.

hajamie
Newbie Poster
4 posts since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

style and script tags should be in the head section of your document.
Clear up your validation errors and it should start working in more browsers.
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.nugit.co.uk%2F%3Fdirr%3D1Home%252F1Products%252F1DVD%2BPlayers%252F2Portable

Stylesheets should have a .css extension.
http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.nugit.co.uk%2F%3Fdirr%3D1Home%252F1Products%252F1DVD%2BPlayers%252F2Portable

DaveSW
Master Poster
769 posts since Jul 2004
Reputation Points: 54
Solved Threads: 20
 

I like having a php style sheet, works in firefox and ie... i could tell the server to parse css files, but it's not my server. Cheers for the help:)

hajamie
Newbie Poster
4 posts since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

Your 100%s and your entire font families should not be in quotes.

width: 100%;
not
width: "100%";

That was the only error flagged on the css sheet. The three warnings are there I think because you have all your fonts in one quotation. You can have them individually in quotes, but not the whole lot. You don't usually need them tho.

DaveSW
Master Poster
769 posts since Jul 2004
Reputation Points: 54
Solved Threads: 20
 

ahhh! nice one, thanks!

hajamie
Newbie Poster
4 posts since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: