473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Need help using DIV's to replace TABLE's

bj
Hi,

Yes, this is yet another "switching from tables to divs for layout
purposes" post. I have been searching for the past few hours to find
what I'm looking for as I hate posting unnecessarily. I am a pretty
crap searcher but I'm kinda sure this hasn't been written about yet.
Please feel free to prove me wrong and link to a solution. Otherwise
I'd appreciate any advice you may have.

I have a situation where I have a window that has been spawned, which
is to display HTML content in a powerpoint-esque way, with header &
footer, a menu to the left, and an iframe (where the content is
loaded/progressed) taking up the rest of the space. It kinda looks like
this:
-------------------------------------
header (stays at X pixels high)
-------------------------------------
|
menu |
(stays | iframe
at | (takes up the rest of the
Z | space in the window, has
pixels | scrollbars turned on for
wide) | content that needs it)
|
|
|
|
-------------------------------------
footer (stays at Y pixels high)
-------------------------------------

(that was designed to look correct & line up using fixed-width font,
sorry if it didn't work. If you paste it into notepad you'll see what I
mean).

So ... the idea is that the footer is always supposed to be at the
bottom of the screen, always visible. The Menu & IFRAME fill out the
rest of the height between the header and footer, with the ability to
resize. If the content in the IFRAME is too long, then a scrollbar
appears between the header & footer (the scrollbars for the main window
are turned off). So far, this has all been easily accomplished with a
table (3 rows, first row header, second row 2 columns: one menu, one
iframe, last row footer). However, I'm following the trend of moving
away from using tables for layout purposes (partly because I need to
make this content w3c accessible), and I've started experimenting with
using DIVs and CSS to do the same thing.

However, I'm having problems with getting the page to appear correctly.
I have tried the following:
<html>
<head>
<style type="text/css">
div.container {
position:relative;
width:100%;
height:100%;
margin:0px;
}
div.content {
position:relative;
width:100%;
height:100%;
border:solid 1px gray;
}
div.header {
position:relative;
width:100%;
border:solid 1px blue;
}
div.footer {
position:relative;
width:100%;
border:solid 1px blue;
}
div.menu {
position:relative;
float:left;
width:190px;
height:100%;
margin:0px;
border:solid 1px red;
}
body {
margin: 0px;
}
#contentFrame {
width:100%;
height:100%
}
</style>
</head>
<body>
<div class="container">
<div class="header" id="header">header here</div>
<div class="menu" id="menu">menu here</div>
<div class="content" id="content"><iframe name="contentFrame"
id="contentFrame" src="about:blank" frameborder="0"></iframe></div>
<div class="footer" id="footer">footer here</div>
</div>
</body>
</html>

This looks horrendous in Firefox, and in IE it's all OK except for the
fact that it is more than 100% high. This is no doubt due to the fact
that I have 3 elements on top of each other, top & bottom have certain
height, middle has 100%, hence > 100% height.

So, if this makes sense, and there's some CSS I'm missing out that will
make it all work, then I'd love to hear from you. Or, if it's been done
already, I'd like to see it (and learn from it). Or, if it can't be
done, then I'll be proven wrong (I told someone "Surely we can
replicate this in CSS?").

Thanks in advance.

bj.

Mar 20 '06 #1
2 7449
bj wrote:

Yes, this is yet another "switching from tables to divs for layout
purposes" post. I have been searching for the past few hours to find
what I'm looking for as I hate posting unnecessarily. I am a pretty
crap searcher but I'm kinda sure this hasn't been written about yet.
Please feel free to prove me wrong and link to a solution. Otherwise
I'd appreciate any advice you may have.

For style: <http://www.csszengarden.com/>. The HTML is not so good. The
site exists to demonstrate the possibilities of CSS.
Modern design and layout:
<http://www.positioniseverything.net/>
<http://css.maxdesign.com.au/>

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Mar 20 '06 #2
bj
Well, I learned a lot from those sites, but still haven't found what
I'm looking for.

Essentially, I need to replicate the behaviour of the following table
layout but without using tables:

<html>
<head>
<style>
body {
margin: 0px;
}
#header {
height:1%;
background-color:#2255aa;
}
#menu {
height:100%;
width:1%;
background-color:#cccccc;
}
#content {
height:100%;
width:100%;
background-color:#aaaaaa;
}
#footer {
height:1%;
background-color:#2255aa;
}
#menuSpacer {
width:160px;
height:0px;
}
</style>
</head>
<body>
<table width="100%" height="100%">
<tr>
<td colspan="2" id="header">This is the header row</td>
</tr>
<tr>
<td id="menu"><img src="spacer.gif" id="menuSpacer"><br>This is the
menu cell</td>
<td id="content">This is the content cell - it will have an iframe
completely filling this cell with with scrolling turned on for pages
that go below the footoer.</td>
</tr>
<tr>
<td colspan="2" id="footer">This is the footer row</td>
</tr>
</table>
</body>
</html>

(Assuming you have a transparent pixel GIF at the same dir level as
this HTML)

So, if I can make this layout work without tables, which I assume means
with DIV's and CSS, then I'd be extremely happy, and appreciative of
whoever provides the answer or points me in the right direction.

bj.

Mar 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
0
by: yurps | last post by:
Hello here is my html, if you click the missing image in the first column on the left, the div is shown, when clicked again the div disappears...but the bottom border disappears as well...Is there...
5
by: news.west.cox.net | last post by:
I have something like this in a function: .... var box = document.getElementById("box"); box.style.visibility = 'hidden'; .... This hides a div setup like the following: <div id="box">
2
by: DBLWizard | last post by:
Howdy All, I am trying to detect if the user has cookies enabled on a page and display text accordingly. My cookie detection works but I can't get the divs to work. Here is the javascript and...
1
by: AMDRIT | last post by:
Hi gang, this is pretty critical to me. Any help you can provide is appreciated. I have a WebBrowser control placed on a form. I am not getting the same results as I am in IE. Here is the...
1
by: darwin2kx | last post by:
I have a problem that I've been tracking down for a while now. I'm working on a script that dynamically adds blocks for data entry to a page. This script works on one page but not another. For some...
1
by: drchaos | last post by:
Placing HTML code with inline javascript into a div both as rendered HTML(the intended final purpose) and shown as RAW text HTML (for the user to copy and paste into their own webpage.) Here is...
2
by: rrowles2000 | last post by:
Hi, I have four chuncks of html and I'm trying to sort them. see this link. Basically the sort works for alphabetic sort but not for numerics. Any ideas very welcome? I just can't see what I'm...
3
by: asafok | last post by:
I have the attached code is the site i'm working on and I need to remove the <br/> node that comes after the " <div id="win_233906"... " my question is : how can I get access to the <br/> and how...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.