473,734 Members | 2,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Lining up four DIVs horizontally

I have four roughly square DIVs, all the same height, which I need to
line up horizontally across the page. What would be the best way to do
this? At the moment I have a very botched solution where I have
display:table-cell set on each of the DIVs. This works as far as
lining them up is concerned, however to get any spacing between them
the only thing I could do was to put some   in between each one
(margin had no effect).

This works, in Firefox & Safari, but not in IE where the boxes line up
vertically. Also, adding an image into one of the divs causes it to go
very weird in firefox. It works fine in Safari.

I would have thought that display:inline; or similar would work for
this, but when I tried that the boxes seemed to lose their boxness.

Hopefully you get some idea of where I'm going with this(!), and any
advice would be appreciated.

A

Jul 24 '07 #1
4 8409
On 24 Jul, 14:12, Adam <kindredhyper.. .@gmail.comwrot e:
I have four roughly square DIVs, all the same height, which I need to
line up horizontally across the page.
Hard to say, without knowing how best they should behave if they
_don't_ fit across the page. Placing each one inside a <tablecell
works, if you really do want a rigid grid behaviour, preserved as much
as possible. Using display:inline; will also work, but as you point
out, they lose "blockiness ". display:inline-block; is often the
perfect solution in principal, but support is too narrow to recommend
using it.

Generally the best all-around solution is to use float. Read
http://brainjar.com/css/positioning/ for a good tutorial on how to,
and how to tidy up with clear afterwards. It's not as simple as you
expect, but it's worth studying, at least for an example.

Jul 24 '07 #2
rf

"Adam" <ki************ *@gmail.comwrot e in message
news:11******** **************@ k79g2000hse.goo glegroups.com.. .
>I have four roughly square DIVs, all the same height, which I need to
line up horizontally across the page. What would be the best way to do
this?
float: left?
At the moment I have a very botched solution where I have
display:table-cell set on each of the DIVs.
IE6 does not support display: table-cell.
I would have thought that display:inline; or similar would work for
this, but when I tried that the boxes seemed to lose their boxness.
A "box" is display: block. If you use display: inline then it is no longer a
"box", it is, er, inline.

display: inline-block is what you are probably looking for but IE6 does not
support this.

--
Richard.
Jul 24 '07 #3
On 2007-07-24, rf <rf@invalid.com wrote:
[...]
>I would have thought that display:inline; or similar would work for
this, but when I tried that the boxes seemed to lose their boxness.

A "box" is display: block. If you use display: inline then it is no longer a
"box", it is, er, inline.
Well, technically the spec does talk of "inline boxes", as opposed to
blocks.
display: inline-block is what you are probably looking for but IE6
does not support this.
Or Firefox.
Jul 24 '07 #4
IE6 does not support display: table-cell.

Interestingly I found that everything started working when I just
added another div with display:table-row; around the boxes. Now it
works in IE6, FF and Safari. How odd...

A

Jul 24 '07 #5

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

Similar topics

3
4799
by: Chris | last post by:
Hi, I am pretty new to CSS authoring and find myself in a tricky situation. I have a series of divs (dynamically generated - there could be up to 8) as follows: <div class="person"> <h2>Name</h2> <img src="images/name.gif" alt="Chris" /> <p>Message Here</p>
20
2865
by: Firas D. | last post by:
http://firasd.org/ The divs of the 'box' class seem to have the effect I want in IE (namely: consistent height and horizontal alignment along the set of divs), but it totally falls apart in Firebird, like the p's inside teh divs are independent of the div's properties... (looked okay until I applied "display: inline;") What would be the proper way (I'm assuming that Firebird is displaying the proper behaviour)?
2
2091
by: BenOne© | last post by:
Hi all, I'm trying to create an image gallery with CSS but I can't get the thumbnails to center horizontally as a group. The page, including css defined in the <HEAD> is located at: http://homepages.ihug.com.au/~benst/pictures/photography/css_problems.html Please note there are only 2 thumbnails on the page so it won't bring your internet connection to its knees.
6
4807
by: skeeterbug | last post by:
please check out http://www.geocities.com/operationsengineer1/test2.htm how come there is spacing between my logoheader and the tabs? i'm also seeing ie6 input an extra 1em of vertical spacing between divs when i use float and clear to get rid of the float. i've searched for this problem for two days and haven't found an answer
2
1951
by: Guadala Harry | last post by:
Please follow my thinking here and tell me if I'm nuts or if this is a reasonable thing to do given the objective: I'd like to present 3 data values on an aspx page - each styled uniquely, and the total width to be limited to some arbitrary value (400px or so). Given that I'd like to limit the total width, I can't use a <td> because the width specified for a <td> specifies a minimum and not a maximum. Consequently I'll use a DIV...
29
1906
by: eholz1 | last post by:
Hello Styleists! I am trying to get a page going similar to this nice tutorial at A List Apart. URL: http://www.alistapart.com/d/holygrail/example_1.html This is sorta what I would like. When I navigate to the page above using Firefox, all is well - the left side (a div column) has text and is colored blue, the center
6
1751
by: Liam Gibbs | last post by:
Hello everyone, I'm trying to program a church web site and I'm having a number of problems with the layout. The html is at http://www.altmarvel.net/Liam/index.html and the css is at http://www.altmarvel.net/Liam/OCOC.css. Anyway, the problems are these: 1. The Search stuff underneath the menu and to the right should be
4
32608
dlite922
by: dlite922 | last post by:
This is just barely above my head when it comes to css. I have a div that needs to contain rows of floating divs, but I need each row not to wrap on to the next one and continue to go right. The user will use a overflow: auto scroll to scroll to see the rest of the divs. illustration: # = === = = === === # = == = = # == ================== # =========
7
5556
by: milestogofromhere | last post by:
It is late so this is probably something really obvious but I am not seeing it. Can someone please help? Here is the page in question: html - http://www.itsyourplate.com/index2.php css - http://www.itsyourplate.com/thin.css As you can see from the file the menu is showing up vertically not horizontally. I copied the code directly from another site I have done and changed the bullets (I didn't want any) and the colors but I must have...
0
8776
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,...
0
9449
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, 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...
0
9310
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 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...
1
9236
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,...
1
6735
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
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
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
2
2724
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.