DIV-lemma

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Warning: I didn't get much sleep last night, so the brain is fuddled...

I'm trying to get two s to show aside each other. Sorta like this:

______________________________________
|   div1    |       div2             |
|           |                        |
|           |                        |
|           |                        |
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
'
This is easily achievable with the use of tables, but I want to try to minimise that this time. Smiling

So far, I've managed to use float:left|right to get something that looks like this:

______________________________________
|   div1    |      div2              |
|           |  the content text      |
|‾‾‾‾‾‾‾‾‾‾‾‾                        |
|  wraps around here                 |
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
'

So... what am I missing? How would I make div1 span 100% in height, as though it were an adjacent cell in a table?

I hope I made some sense...

All comments and suggestions welcome. Smiling

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Well, whaddya know. I think i fixed it. Smiling

Put my two s inside another with display:inline-block. Seems to work fine so far... Smiling

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

First, float and clear are your friends. Float the left one left and the right one right. Depending on which one is going to have more content, clear one side or the other.

It works to make it so they are like side-by-side table cells.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Or nesting, but that's still being presentational instead of structural or semantic -- try it without the nesting. Wink

** I'm not saying it's wrong, just that I personally subscribe to the idea of the semantic web.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Thanks for replying. Smiling

It isn't just the text-wrap that is a problem. I also have similar setups repeating one below the other. I used the same #id for each with the same formatting, so when I apply float:left|right, they end up trying to float to the previous "row", as it were. Sad

Easiest way out was nesting. Sticking out tongue I'll try again without nesting. Wink

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

... you have the same #id twice on the same page? No can do, buckaroo!

Busy's picture

He has: 6,151 posts

Joined: May 2001

.left {
float: left;
text-align: left;
color: #fff;
width: 50%;
}

.right {
float: right;
text-align: right;
color: #fff;
width: 50%;
}

and for the actual display:

left section left
right section right

and if you make the width on the main display under, say half, use something like or in a div as you can have other stuff trying to go beside it.
If you want the content center, change the text-align: in the style to center or remove it

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Thanks, Busy. Smiling

That's pretty much what I already got... Wink

But what does do? Is it not the same as a ? I don't think I follow. Confused

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Add note: the problems with the overlapping s came down to sloppy coding — missed ; and units etc. Works now without nesting. Wink

Busy's picture

He has: 6,151 posts

Joined: May 2001

its works more if your using multi float div's but its like saying "anything above this has to stop here" so the above can't "flow" into lower sections

hope that explains it, it's kind of one of those things that just is lol

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Using a for that is still presentational markup, but it does work (did it myself until recently when I finally got the whole thing straight in my head and moved to XHTML 1.0 Strict).

The folks chit-chatting at CSS-Discuss go over and around this issue a lot -- whether to use hacks in the markup v. hacks in the CSS and how lamentable that hacks are still required, even though they are so much smaller and more efficient hacks now. Wink

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

I'm shocked: my first attempt at XHTML & CSS and the page validated to XHTML Strict 1.0! :eek:

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

WHOOOO!!! Way to go! Smiling

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

heh thanks. Smiling

Now I just have to get the CSS all validated and ready to go. Wink

After one night of CSS, I can't imagine how I ever put up with nested tables. Creating this single page took me less than half the time it would've taken me with HTML4. And it's better looking too. Even compatible with 3 browsers - IE6, O6, NS6 (I'll post it up for compatibility testing soon). Laughing out loud

Edit: CSS passed too. Smiling Oooo I'm feeling all warm and fuzzy. Sticking out tongue

Busy's picture

He has: 6,151 posts

Joined: May 2001

Congrats dude, drinks are on you Wink

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

Can't wait to see the page, might even spur me on to try Wink

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

For a limited time only: http://210.54.113.176/public/DEV/C3S/C3S.php

Hurry before my IP changes. Wink (I need a more permanent PHP host. Desperately. Sad )

The design isn't all that flashy, but it works ok. The content is just documentation-type stuff.

I took up Busy's idea of a graphic-less site and avoided using titles/banners and the like in graphical format. Kept it to a minumum. Wink

My stylesheets are a bit messy, but they validate. Right now, I'm playing around with alternate stylesheets — Print Friendly, etc.

The content itself is just something a friend and I developed over time for fun. If you have a few minutes to kill, this'll waste your time nicely. Laughing out loud

Busy's picture

He has: 6,151 posts

Joined: May 2001

Thats great (did you set a background color?)

puts my graphic less thing to shame

^9 Laughing out loud

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

So is this the way forward with graphicless sites?? Not to say that either of yours aren't good but isn't is going to get boring without graphics?

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Oh not at all. I'd love to have used graphics, but the content style wouldn't suit it. This is meant to be more like a php.net or w3.org page... just plain old content-oriented documentation. Wink

For most other concepts, I would've used much more imagery. Smiling

Busy's picture

He has: 6,151 posts

Joined: May 2001

I did mine cause am trying to keep the bandwidth down, but I am tiring of slow loading graphics, esp flash and slow loading pages, downfalls of 56k.
msn (hotmail) is even using the marquee tag now, real annoying.
Maybe we could start a new trend, I know of a few other people working on graphic-less sites

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

Try selling that concept to clients who want every picture of every products plus ones of the office and anything else they can come up with and then on top of that animated gifs, flashy useless flash and funky layout designs!!!

Julia - if life was meant to be easy Michael Angelo would have painted the floor....

Busy's picture

He has: 6,151 posts

Joined: May 2001

I know, remember that quad adventure site I did, they want a animated bike running over the page *Sigh* hopefully can talk them out of it. am glad webpagesthatsuck are around

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Clients aren't minimalists. I don't think you should even think about selling graphicless sites. Wink

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

my earliest site were graphicless! lol aye abhi! hehe Wink but thne again i didn't know how to markup that well :S i'm think i'll start do join the trend ...

dk01's picture

He has: 516 posts

Joined: Mar 2002

Hey Abhishek when you get a chance could you attach your code. I have been doing css now too any would like to see it. Thanks.
-dk

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

k, you want the stylesheet or the whole thing?

sitebug.com/C3S/

You can get the stylesheets there in /styles. .phps added.

Wink

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

About going entirely without graphics -- I think it's a horrible idea in general, however, there are many many good publications out there that don't use graphics for most of the page elements, only illustrations for articles and such.

Robin Williams explains the use of colour on a page (black and white, weights of text and such, not red, blue, yellow kinds of colour) really well: http://www.eyewire.com/magazine/columns/robin/blacknwhite/

Now back to your regularly schedule glee at CSS/XHTML that works! Laughing out loud

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

I suppose there's also the question of just what a graphic is...

It doesn't strictly have to be a "graphic file". For example, on the page I made, I use divs and text with a bit of formatting - and that serves sufficient eye candy. ATM, there's no need to do any more for fear of over-doing it as it works fine the way it is.

Then again, this isn't a whole site as such. It's a single document, so I can get away with sending the jpgs and gif on holiday. Wink

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.