Forum Moderators: not2easy

Message Too Old, No Replies

Layout Problem

         

ReeD

11:43 am on Aug 1, 2005 (gmt 0)

10+ Year Member



Hello, I'm new here. I have a problem with my layout. It's actually very simple but it doesn't work as intended.

Here's the html (you can simply copy-paste it):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1257" />
<title>Administrative Interface</title>
<style type="text/css">

html
{
margin: 0;
width: 100%;
height: 100%;
}

body
{
background-color: #E6E6E6;
font-family: verdana;
font-size: 0.8em;
display: table;
color: #000000;
margin: 0;
width: 100%;
height: 100%;
}

.light_bg
{
border: 1px solid #C4DBE1;
background-color: #E1EDF0;
}

#container
{
display: table-cell;
vertical-align: middle;
}

#content
{
display: table;
margin: 0 auto;
}

#header
{
width: 100%;
height: 4.8em;
margin-bottom: 10px;
}

#menu
{
float: left;
text-align: left;
height: 100%;
padding: 10px;
}

#page
{
float: right;
width: 700px;
height: 390px;
margin-left: 10px;
}

</style>
</head>
<body>

<div id="container">
<div id="content">
<div id="header" class="light_bg"></div>
<div id="menu" class="light_bg">adjavhdvahdafwfw</div>
<div id="page" class="light_bg"></div>
</div>
</div>

</body>
</html>

You can see that #page and #header have missing borders. Another problem is that if you increase font size (in your browser), the layout gets screwed up.

I would be glad if someone could explain me what is wrong with my code and how I could fix it. It's such a simple thing, but somehow it doesn't work right...

abbeyvet

12:20 pm on Aug 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am not sure what effect you are after, but there is a lot of stuff that seems extraneous in there.

For example:

You do not heed a html selector here
display:table seems unnessesary
the container and content divs seem to be doing nothing.

Not floating the page div, but instead giving it a left margin and removing its height will stop it dropping down the page when at higher res/smaller screens. 700px is too wide, it will fall off the edge.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1257" />
<title>Administrative Interface</title>
<style type="text/css">

body
{
margin: 0;
background-color: #E6E6E6;
font-family: verdana;
font-size: 0.8em;
color: #000000;
margin: 0;
width: 100%;
height: 100%;
}

.light_bg
{
border: 1px solid #C4DBE1;
background-color: #E1EDF0;
}

#header
{
width: 100%;
margin-bottom: 10px;
}

#menu
{
float: left;
text-align: left;
height: 100%;
padding: 10px;
}

#page
{
height: 390px;
margin-left: 100px;
}

</style>
</head>
<body>

<div id="header" class="light_bg">header</div>
<div id="menu" class="light_bg">menu</div>
<div id="page" class="light_bg">page</div>

</body>
</html>

I took a lot of it out and it seems to work fine now, but as I said I don't know what you are after to the bits I removed may have some function I am not seeing.

Use this as a starting point and see who you go.

ReeD

12:45 pm on Aug 1, 2005 (gmt 0)

10+ Year Member



thanks for your quick reply. i have just copy-pasted your exact code into a new html, and it seems to be not working well. the layout is not near similar to mine... are you sure it woks well on your side?

here are a few comments:

You do not heed a html selector here

I do. Otherwise, the layout won't be centered vertically.

display:table seems unnessesary

I think it is, in both body and #content. For body it is there because #container is table-cell, and for #content it allows centering the content inside it horizontally without knowing its actual width.

the container and content divs seem to be doing nothing.

They do something. :). #container centers the layout vertically, #content - horizontally.

If I'm incorrect somewhere, please point that out. ;)

Also according to my idea, #menu and #header should have no fixed width, #page should have both width and height fixed. The idea is to allow text to be resized (via browser), so #menu would shrink to accomodate the text within it (#header woudl also shrink accordingly).
It seems very easy, but somehow it just doesn't work...

abbeyvet

1:31 pm on Aug 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry about that - I just took a quick look a jumped to conclusions based on how it looks in IE, which is definitely not what you are after. Take a look.

I do not believe that what you are trying to do, at least the way you are approaching it, will work in IE, or at least not without multiple hacks.

Maybe that doesn't matter?

ReeD

2:01 pm on Aug 1, 2005 (gmt 0)

10+ Year Member



well, yes it's for my personal use. but anyways, 50% what is correct doesn't work with IE... at least they seem to be working on IE7, which may make lives of many at least a bit easier.

ReeD

5:25 pm on Aug 1, 2005 (gmt 0)

10+ Year Member



really no way to correct tehe errors? i'm begining to loose hope... can't find a good way to do it. :(

drhowarddrfine

6:49 pm on Aug 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You say they are missing borders but I see the 1px borders.

One problem is your header is listed as 100% width; When you resize the font, the header is the only thing keeping the content div the width that it is. So the page div can't fit when the font is enlarged so it disappears off the screen somewhere. If you set #header to 100%, that solves that part of the problem.

ReeD

9:01 am on Aug 2, 2005 (gmt 0)

10+ Year Member



I have found on w3.org that floated elements MUST have width specified. In my case #menu doesn't have width specified and it is floated, thus the layout doesn't work.