[RESOLVED] <div> as <table> and background-color issue
Here's a simple example of as close as I've gotten trying to be a good programmer and learn some newer techniques (when I was your age...we made <tr> and <td> tags ... up hill! ... both ways!! ... and we 'liked' it!!! ), and I've hit a bit of a wall understanding how to deal with height.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en-gb" lang="en-gb" >
<body>
<div align="center">
<div id="bodywrap">
<div id="mainwrap">
<div id="main_l"><div id="main_lp">Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left </div></div>
<div id="main_r">Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right </div>
</div>
<div id="break" />
</div>
</div>
</body>
</html>
I'm trying to get div#main_l to be that color for as tall as div#main_r ends up being, or vice versa, depending on the content (which will vary, can be text, or images...beef or chicken, at this point, we don't know).
With tables, the cell with the most stuff wins, and everyone else in the row complied. Here, it seems to break down when the 'floating' begins. I tried playing the absolute, and that doesn't work so well. Position = relative was 'close' in some cases, until you start using ctrl+ to increase the font size, and then the relative position starts to **** and make a nasty mess out of it.
So I'm 'really' close, at least I think. background-color: transparent works fine right up until I start floating those divs, then they seem to lose the ability to be transparent.
Any ideas? Is this one of those situations where you have to use a table with one row and two columns and 'then' load it up with all the divs and spans you need?
The `break' is in the wrong place. If you used indentation, you'd see that it is outside of `mainwrap'. Without it being inside of `mainwrap', your floats won't clear properly:
Code:
Right Right Right Right Right </div>
</div>
<div id="break" /> <!-- Move this line up one to fix it. -->
</div>
Tested in Fx3, Opera, Google Chrome and IE8b2 (with IE8 mode, IE7 mode and IE7 emulation mode). I hope this helps!
The `break' is in the wrong place. If you used indentation, you'd see that it is outside of `mainwrap'. Without it being inside of `mainwrap', your floats won't clear properly:
Code:
Right Right Right Right Right </div>
</div>
<div id="break" /> <!-- Move this line up one to fix it. -->
</div>
Tested in Fx3, Opera, Google Chrome and IE8b2 (with IE8 mode, IE7 mode and IE7 emulation mode). I hope this helps!
Actually there's still a problem
That solves the issue when the content of the left div is always smaller than the right, but if you fill up that left div with a lot of 'lefts' so it has more content than the right side, the right side is only as high as it's content and doesn't grow as the left div grows.
Well, there is a technique known as faux columns. Basically, you apply a vertically-tiled background-image to your wrapper div, and then your columns appear to be real columns. You wouldn't need background colors then. Your background image could be 1 pixel high, with the specified widths for your columns' backgrounds.
Well, there is a technique known as faux columns. Basically, you apply a vertically-tiled background-image to your wrapper div, and then your columns appear to be real columns. You wouldn't need background colors then. Your background image could be 1 pixel high, with the specified widths for your columns' backgrounds.
What's funny is I started down this road before, and had 'everything' that site was talking about except one important thing. I had a 100x2 black image, and through I could start it at 539px and 'repeat', and it wouldn't 'back' bleed, if that makes any sense. I think that's a poor implementation, if you ask me (unless I'm missing something). If I say I want to start something at 539px and repeat it 'both' horizontally and vertically, I should be able to.
At any rate, while the article didn't specifically say it, it hinted at the fact that I 'must' only use repeat-y, and the logical conclusion is that my placeholder image be the width I want, with the height being a few pixels.
Implemented it, works like a champ (and this time...I'll use 'code' ):
(note: mb_black.png attached, if anyone wants to test this and finds the solution in this discussion useful)
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en-gb" lang="en-gb" >
<body>
<div align="center">
<div id="bodywrap">
<div id="mainwrap">
<div id="main_l"><div id="main_lp">Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left
Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left
Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left Left
</div></div>
<div id="main_r">Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right Right </div>
<div id="break" />
</div>
</div>
</div>
</body>
</html>
You can test it by taking out a few lines of 'left' in the 'main_lp' div and putting them back. Desired effect achieved!
Note: I 'still' question the implementation of repeat on background and background-repeat, however. It seems it would be far more flexible if my background control image could only be a few pixels wide, and I could tell it exactly where I want it, and when I say 'repeat', it never repeats to the 'left' of my starting horizontal position (or above my starting vertical).
At any rate (I say that a lot). All your input was greatly appreciated, got me down the right path each time.
Bookmarks