473,386 Members | 1,801 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.

Generalized Side by Side Divs

I've been trying to wean myself off of tables. I've been reading about
the float property, and have implemented a couple of sites using divs
instead of tables, and generally I'm happy with the results.

Still, I'm having problems constructing a generalized approach to
laying divs side by side without being very specific about the width of
each div. The code below makes 3-columns of content, but unfortunately
if the visitor resizes the page large enough eventually the 3rd column
drops down below the second. I had hoped that the nowrap on the
bounding div would stop the problem.

Can anyone point me in the direction of how to do this? Ultimately I'd
like to be able to have 23 side by side columns if I like with the
assurance that they'll remain locked side by side. Any online
tutorials I might have missed would be extremely helpful - I've read
many so far, and also the float section in the Schengili/Roberts "Core
CSS" book but I can't find a clear answer on how to approach this
problem.

Thanks!
philz

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Upcoming Events &amp; Workshops</title>
<style type="text/css" title="test">
<!--
BODY {
background-color: #000000
text-color: #ffffff;
color: #ffffff;
font-family: Arial, Verdana, Helvetica, sans-serif;
font-size: small;
}

div
{
margin: 0px;
padding: 0px;
}

..columnOne {
float: left;
padding: 4px;
border: none;
color: #ffffff;
margin-left: 0px;
p\osition: relative;
}
..columnRight {
float: left;
padding: 4px;
border: none;
color: #ffffff;
margin-left: 4px;
margin-right: 4px;
p\osition: relative;}

..zTextLarge {
color: #ffffff;
font-size: large;
font-family: Arial, Verdana, Helvetica, sans-serif;
font-weight: bold;
}
-->
</style></head>
<body text="#FFFFFF" bgcolor="#000000" link="#0000FF" vlink="#551A8B"
alink="#0000FF">

<p>
This is a test of CSS Float properties
</p>

<br><br>
<br><br>

<div style="nowrap" align="left">
<div class="columnOne">
<span class="zTextLarge"><u>Performances</u></span>
<br><br>
content 1<br>
content 1<br>
content 1<br>
content 1<br>
content 1<br>
</div>

<div class="columnRight">
<span class="zTextLarge"><u>Vocal Workshops</u></span>
<br><br>
content 2<br>
content 2<br>
content 2<br>
content 2<br>
content 2<br>
</div>
<div class="columnRight">
<span class="zTextLarge"><u>Other Workshops</u></span>
<br><br>
content 3<br>
content 3<br>
content 3<br>
content 3<br>
content 3<br>
content 3<br>
</div>
</div>

</body>
</html>
Jul 21 '05 #1
5 8373
On Fri, 01 Apr 2005 10:57:32 -0500, squidco
<za*****@squidcoRemoveMe.com> wrote:
Ultimately I'd
like to be able to have 23 side by side columns if I like with the
assurance that they'll remain locked side by side.


floats will drop if there is not enough room to contain all of them
so
set the width of the containing div to be larger than 100%, try 200 or
250%

people with low resolutions(800) will have a long horizontal scroll,
people with high resolution (1600) will be able to see everything side
by side.

but there is no assurance with floats. People who browse in
non-maximized windows will see a blank space somewhere.
cheers
johnSteve
Jul 21 '05 #2
Thanks johnSteve, that did the trick...

I'm curious what you mean by non-maximized windows, do you mean older
browsers? I don't see any unexpected blank space with Firefox, IE or
Safari on the Mac, modern versions all - this looks like exactly the
solution I was looking for.

philz
In article <k4********************************@4ax.com>, johnSteve
<st****@bresnan.net> wrote:
On Fri, 01 Apr 2005 10:57:32 -0500, squidco
<za*****@squidcoRemoveMe.com> wrote:
Ultimately I'd
like to be able to have 23 side by side columns if I like with the
assurance that they'll remain locked side by side.


floats will drop if there is not enough room to contain all of them
so
set the width of the containing div to be larger than 100%, try 200 or
250%

people with low resolutions(800) will have a long horizontal scroll,
people with high resolution (1600) will be able to see everything side
by side.

but there is no assurance with floats. People who browse in
non-maximized windows will see a blank space somewhere.
cheers
johnSteve

Jul 21 '05 #3
squidco <za*****@squidcoRemoveMe.com> wrote:
Ultimately I'd like to be able to have 23 side by side columns if I
like with the assurance that they'll remain locked side by side.

If it's tabular data, then use a table. If it isn't tabular data, then why
worry about having 23 columns "locked" into one particular configuration?

squidco <za*****@squidcoRemoveMe.com> wrote: I'm curious what you mean by non-maximized windows, do you mean older
browsers?


No, not at all. Even the newest browsers come with non-maximized windows by
default. They're just windows that don't take up the full display. For
example, my default browser windows are about 600x800 (yes, taller than
they are wide) on a display that's configured for 1280x1024 resolution.
--
Darin McGrew, mc****@stanfordalumni.org, http://www.rahul.net/mcgrew/
Web Design Group, da***@htmlhelp.com, http://www.HTMLHelp.com/

"I can take one day at a time, but sometimes several days attack me at once."
Jul 21 '05 #4
squidco <za*****@squidcoRemoveMe.com> wrote:
Ultimately I'd like to be able to have 23 side by side columns if I
like with the assurance that they'll remain locked side by side.


Sounds like tabular data. If this is the case, use a table for it.

Bye,
Martin
Jul 21 '05 #5
In article <d2**********@blue.rahul.net>, Darin McGrew
<mc****@stanfordalumni.org> wrote:
squidco <za*****@squidcoRemoveMe.com> wrote:
Ultimately I'd like to be able to have 23 side by side columns if I
like with the assurance that they'll remain locked side by side.

If it's tabular data, then use a table. If it isn't tabular data, then why
worry about having 23 columns "locked" into one particular configuration?


This is really more of a theoretical issue for me - I've had some
arguments recently with a web developer who refused to put some data
into a table even though we were having serious cross-browser layout
problems that could have been easily solved by tables. Eventually he
agreed with me and reverted to a table, but his comment was that "I
stopped using tables a couple of years ago". This led me to my
question, and to a change in my development practices to try to reduce
the number of tables I use and to rely on CSS more to simplify my
layouts.

What's not theoretical is a site I'm working on now that is using two
columns of text. I found a reliable way of laying them out using fixed
widths, but I became interested in whether this problem could be solved
without fixed widths, and then to this question, whether I could
generalize the solution for any number of columns.

So generally, yes, if my layout required 23 columns I'm sure I'd use a
table, but it's very interesting to see that there is a CSS solution.
The solution itself is a bit weird - I generally don't like to declare
widths like 200%, which sounds like a kludge that might get "fixed" at
some point in the future. Still, that seems to be the state of CSS
still, and why I've done less with it than I might have over the last
few years: there are a lot of tricks to get around browser
implementations, and parameters like float are kind of flakey.

squidco <za*****@squidcoRemoveMe.com> wrote:
I'm curious what you mean by non-maximized windows, do you mean older
browsers?


No, not at all. Even the newest browsers come with non-maximized windows by
default. They're just windows that don't take up the full display. For
example, my default browser windows are about 600x800 (yes, taller than
they are wide) on a display that's configured for 1280x1024 resolution.


Doh! Of course I should have known what you mean, even though I'm a
Mac developer... I just don't really think about maximized width, just
browser width. I always check pages as though I had a tiny browser
window or a huge window, resize the fonts on every page up and down,
etc. to flush out potential layout flaws.

philz
Jul 21 '05 #6

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

Similar topics

9
by: Preston Crawford | last post by:
I know this is probably a dumb question so please be patient with me. I've been doing HTML since 1994, but mostly for projects that had to be as completely compatible as possible and mostly...
4
by: Aaron | last post by:
I have the following divs: <div style="background-image: url(images/house_01.jpg); width: 249px; height: 346px;"></div> <div style="background-image: url(images/house_02.jpg); width: 251px;...
2
by: Jamie Jackson | last post by:
I'd like to get a couple of divs centered in a container (let's say the container is a td, but it could also be a div). Here's what I have now (div2 and div3 are floated left):...
6
by: Mel | last post by:
i need to have as many as 5 divs side by side on the same line without a break. if browser displays a horizontal scrollbar, its ok with my users and they can resize it. something like the...
9
by: Screwball | last post by:
Hi, I'm having problems getting 2 divs to display side-by-side correctly. I've done the google bit, but cannot find anything which is similar enough to what I want. Most of the descriptions I've...
4
by: Rick Brandt | last post by:
Sorry, I don't have a sample web page, but hopefully the crude illustration below will suffice. Given that the space within the dashed upper and lower lines is a div across the entire width of...
2
by: Wes Groleau | last post by:
I have a huge pile of open-source PHP, far too big for me to wrestle it into submission. It generates nested tables MANY layers deep. What I am trying to do is extract several small pieces...
5
by: Mike P | last post by:
How would I show or hide a div that is using client side Javascript based upon a server side variable? Here are my divs : <div id="idButton5" class="otherLeftBarLink" onmouseover="javascript:...
2
by: jeddiki | last post by:
How do I get these 2 divs to be side by side ? I have been trying to apply the float logic to a couple of divs on the same screen, but without success. There is a main div that holds two...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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.