473,837 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:relati ve;
width:100%;
height:100%;
margin:0px;
}
div.content {
position:relati ve;
width:100%;
height:100%;
border:solid 1px gray;
}
div.header {
position:relati ve;
width:100%;
border:solid 1px blue;
}
div.footer {
position:relati ve;
width:100%;
border:solid 1px blue;
}
div.menu {
position:relati ve;
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="containe r">
<div class="header" id="header">hea der here</div>
<div class="menu" id="menu">menu here</div>
<div class="content" id="content"><i frame name="contentFr ame"
id="contentFram e" src="about:blan k" frameborder="0" ></iframe></div>
<div class="footer" id="footer">foo ter 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 7471
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.csszengarde n.com/>. The HTML is not so good. The
site exists to demonstrate the possibilities of CSS.
Modern design and layout:
<http://www.positionise verything.net/>
<http://css.maxdesign.c om.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">Thi s 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">Th is 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">Thi s 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
6336
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, column 13: there is no attribute "SRC" <bgsound src="C:\My Documents\zingwent.mids"> You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is...
0
2742
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 anyway to stop this...??? <HTML> <HEAD> <title>Conform Inbox</title> <meta content="False" name="vs_snapToGrid">
5
6909
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
1610
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 html does anybody have any sugestions? <script language="JavaScript"> function window_onload() { var sCookie;
1
1451
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 deal, I dynamically load the HTML into the WebBrowser control, then I invoke a script that passes in XML data to the document. The XML data is not that large, say if it were recipies, it would have maybe 4 recipies in it.
1
1752
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 unknown reason, it seems to be stripping out tags. (And yes, I know the code looks a little messy. It's dynamically created by PHP, and I have to tidy it up a bit still.) What seems to happen is when a link is clicked to add an input, it appears to...
1
3043
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 the setup. Yes, this is a heavily dynamic and AJAX driven page. one section shows both a display of raw HTML code for the purpose of a user being able to copy paste this code (which contains inline javascript) into their own webpage. a sample...
2
7786
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 doing wrong!!! Cheers http://cricketclub.wherwell.net/bowling-averages-2007.htm each chunk looks like this...
3
1302
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 can I replace it with an empty string or even remove it completely. The Code: <table> <tr> <td valign="top" style="width: 140px; direction: rtl; background-color: rgb(153, 203, 228); height: 321px;"> ...
0
9851
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9695
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10286
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9420
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7824
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5680
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4060
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.