jhardman 3,406
Recognized Expert Specialist
I'm almost to the point of using tables to position my elements. That is how bad this is.
So here's the rundown. I have an old page (created by someone else) that I was trying to update to reasonable standards. It has a header bar across the top and a footer bar across the bottom. The rest of the page is divided into two columns, a side bar on the left with info about the international organization, and the rest is info about the local chapter. The first thing I did was take out the table-based positioning and put everything in divs, but I keep running into problems. The worst part is that I know it would look fine in tables.
problem details: If I make the two divs in the center have absolute positioning, there is no way to predict the position of the bottom div to prevent it from covering up those above it. If I make one of the two divs float to one side or the other, the other div will wrap around it, and I want to maintain clean columns. I thought I could nest the two central divs in an outer div , then set the inner divs to style="bottom: inherit" or style="height: 100%" to prevent wrapping, but I couldn't find a solution.
Here's the code with which I ended up: - <body>
-
<div style="width: 100%; height: 55px; background-color: #ccffff;">Header
-
bar</div>
-
-
<div style="width: 251px; height: 300px; background-color: #ffccff;
-
left: inherit; position: absolute;">Side bar
-
</div>
-
-
<div style="position: relative; margin-left: 260px;">Main content div with
-
a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info
-
Main content div with a lot of info</div>
-
-
<div style="width: 100%; height: 100px; background-color: #ffffcc;">footer
-
bar
-
</div>
-
-
</body>
-
This code works fairly well for the amount of info on the screen, and at my screen resolution, however this layout fails at higher resolution (footer is partially covered by side bar). There has got to be another solution.
Jared
3 2046
You need to contain the left and main content divs so the footer doesn't climb in there. You also have some unnecessary styling.
[HTML]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<style type="text/css">
</style>
</head>
<body>
<div style="height: 55px; background-color: #ccffff;">Heade r
bar</div>
<div style="overflow :auto">
<div style="width: 251px; height: 300px; background-color: #ffccff;
float:left">Sid e bar
</div>
<div style="">Main content div with
a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info
Main content div with a lot of info</div>
</div>
<div style="height: 100px; background-color: #ffffcc;">foote r
bar
</div>
</body>
</html>
[/HTML]
jhardman 3,406
Recognized Expert Specialist
Thanks doc, that worked except I am also trying to avoid the main content div wrapping around the side bar - keeping it looking like a nice clean column. Your solution still allows the content to wrap around the floated box.
I've got another sol'n that works a little better, but it's a bit complicated, I can't help but think there must be a better fix. I ended up putting the side bar position: absolute; and moved the main content div over 251px with either padding or margin, then set a min-height: 300px on the containing div you suggested. Can you think of any other way to do it?
Jared
jhardman 3,406
Recognized Expert Specialist
arggh. I sent my IE into glitch mode, got it working by switching to HTML strict. I got in the habit of using transitional, and it is now a little hard to break.
Jared
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: javaguy |
last post by:
I have a data entry web application that is formatted heavily
with tables. Having learned a bit of CSS, I'm hoping to rewrite
this using <div> tags. But I have run into a formatting problem
that keeps me from a solution. I'm hoping for some trick.
Assume that "label_a" is a <label> tag and "INPUT_A" is
an <input> tag. A sample of my current web page is:
<table>
<tr><td>label_a</td><td>INPUT_A</td>
|
by: meltedown |
last post by:
I have 2 left floating divs on a page. Sometime the left side is larger,
sometimes the right side is larger. I want the page to have a margin at
the bottom of whichever div is the largest.
If I put a bottom margin on one of the divs, it might not be the largest
div, in which case the margin won't show up. If I put the margin on both
divs, when the right floats below the left side in a small window, there
is too much margin between the...
|
by: laredotornado |
last post by:
Hello,
I'm trying to write TABLE-free HTML pages, but I'm having a problem
with rewriting a particular block of code using DIVs and CSS. I want
to align the "More" button at the bottom right of the block, which is a
fixed height in pixels. However, there doesn't seem to be a
"float:bottom right" attribute and "vertical-align:bottom" doesn't seem
to work in the DIV of the below
<table cellpadding="0"
|
by: roula |
last post by:
I HATE DIVS AND DIFFERENT BROWSERS!!! i spent the whole day and night searching for a way to center align stupid divs, the problem is that the code is so sensitive, i lost my mind trying to make them work in a certain way (like some should scroll with a fixed background and others shouldn't scroll bla bla..) and the divs are nested and positioned in different ways and if i change something it gets messed up and what works in in IE doesn't work...
|
by: esteuart |
last post by:
I need to get the right combination for a div to clip any text inside and allow vertical alignment. I only have this problem in FireFox. I have 3 divs nested within each other. The outer div has display of table, the first inner div has display of table-cell and the inner-most div has the text. The outer div has a set width and height.
So here's the problem:
Without the inner divs having a width and height set, the overflow:hidden doesn't...
| |
by: Dave Rado |
last post by:
Hi
See my mock-up at http://tinyurl.com/35tv29. The three icons are
supposed to be vertically aligned on their bottoms (using "vertical-
align: bottom"), but they aren't, they're vertically aligned on their
tops. Is there any way to align them vertically on their bottoms (or
middle for that matter) short of resorting to using a table (where
"vertical-align: bottom" does work)?
Dave
|
by: Max2006 |
last post by:
Hi,
I have a TreeView and this is my node style:
<asp:TreeNodeStyle ForeColor = "#000000" Font-Size="9px" Font-Bold="false"
Width="100px" NodeSpacing="3px" />
The problem is the expand button (+) resides right at the middle of
multi-line text. Can I make the expand button top align instead of middle
align?
|
by: Steve Swift |
last post by:
I'm still trying to learn CSS and the use of DIV, and a few examples
will get me started.
My challenge at the moment is to place some text to the right of a
header (a sort of footnote) and to have the baselines of the text
aligned. I can do this with a table:
<TABLE><TR VALIGN=BASELINE><TD><H2>Header</H2><TD>Comment</TABLE>
But my feeble attempt with DIVs fails:
|
by: Ciary |
last post by:
hi fellow coders,
i'm not sure if this is the right place to ask since it's rather specific. i've got some questions using EXT JS. i've been asking on there forum but i didn't get a reply there.seems like their forum is rather lazy compared to bytes :)
anyway, i'm trying to vertically position my text within my divs and doing this dynamically with a button. i figured out i needed to do this and i've done it using JS
align: top
<div...
|
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...
|
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,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |