|
|
|
Next: Creating a rectangle with round angles
|
| Author |
Message |
External

Since: Jul 19, 2007 Posts: 3
|
(Msg. 1) Posted: Tue Jul 24, 2007 1:12 pm
Post subject: Lining up four DIVs horizontally Archived from groups: comp>infosystems>www>authoring>stylesheets (more info?)
|
|
|
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 |
|
| Back to top |
|
 |  |
External

Since: Jun 01, 2007 Posts: 134
|
(Msg. 2) Posted: Tue Jul 24, 2007 1:12 pm
Post subject: Re: Lining up four DIVs horizontally Archived from groups: per prev. post (more info?)
|
|
|
On 24 Jul, 14:12, Adam <kindredhyper... RemoveThis @gmail.com> wrote:
> 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 <table> cell
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. |
|
| Back to top |
|
 |  |
External

Since: Jul 24, 2006 Posts: 224
|
(Msg. 3) Posted: Tue Jul 24, 2007 1:26 pm
Post subject: Re: Lining up four DIVs horizontally Archived from groups: per prev. post (more info?)
|
|
|
"Adam" <kindredhyperion.RemoveThis@gmail.com> wrote in message
news:1185282760.406734.241610@k79g2000hse.googlegroups.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. |
|
| Back to top |
|
 |  |
External

Since: Sep 30, 2005 Posts: 2391
|
(Msg. 4) Posted: Tue Jul 24, 2007 1:30 pm
Post subject: Re: Lining up four DIVs horizontally Archived from groups: per prev. post (more info?)
|
|
|
Adam wrote on 24 jul 2007 in comp.infosystems.www.authoring.stylesheets:
> 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.
>
<style type='text/css'>
..f {float:left;width:24.5%;border:solid black 1px;color:red;}
..f1 {background-color:#eef;}
..f2 {background-color:#fee;}
</style>
Test<br>
<div class='f f1'>A</div>
<div class='f f2'>B</div>
<div class='f f1'>C</div>
<div class='f f2'>D</div>
<br>Test
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress) |
|
| Back to top |
|
 |  |
External

Since: Jul 19, 2007 Posts: 3
|
(Msg. 5) Posted: Tue Jul 24, 2007 1:31 pm
Post subject: Re: Lining up four DIVs horizontally Archived from groups: per prev. post (more info?)
|
|
|
> 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 |
|
| Back to top |
|
 |  |
External

Since: Sep 30, 2006 Posts: 838
|
(Msg. 6) Posted: Tue Jul 24, 2007 3:09 pm
Post subject: Re: Lining up four DIVs horizontally Archived from groups: per prev. post (more info?)
|
|
|
On 2007-07-24, rf <rf.TakeThisOut@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. |
|
| Back to top |
|
 |  |
External

Since: Aug 25, 2006 Posts: 13
|
(Msg. 7) Posted: Sun Sep 09, 2007 9:18 pm
Post subject: Re: Lining up four DIVs horizontally Archived from groups: per prev. post (more info?)
|
|
|
Evertjan. wrote:
> Adam wrote on 24 jul 2007 in comp.infosystems.www.authoring.stylesheets:
>
>> 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
snip
>>
>
> <style type='text/css'>
> .f {float:left;width:24.5%;border:solid black 1px;color:red;}
> .f1 {background-color:#eef;}
> .f2 {background-color:#fee;}
> </style>
>
> Test<br>
> <div class='f f1'>A</div>
> <div class='f f2'>B</div>
> <div class='f f1'>C</div>
> <div class='f f2'>D</div>
> <br>Test
>
This works better in FF if D is not floated.
With the float on D, it can jump to the next row in a narrow window, and
push the second test way out to the right!
Regards
Ian |
|
| Back to top |
|
 |  |
External

Since: Sep 30, 2005 Posts: 2391
|
(Msg. 8) Posted: Mon Sep 10, 2007 2:16 pm
Post subject: Re: Lining up four DIVs horizontally Archived from groups: per prev. post (more info?)
|
|
|
Ian Hobson wrote on 09 sep 2007 in
comp.infosystems.www.authoring.stylesheets:
> Evertjan. wrote:
>> Adam wrote on 24 jul 2007 in
>> comp.infosystems.www.authoring.stylesheets:
>>
>>> 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
> snip
>>>
>>
>> <style type='text/css'>
>> .f {float:left;width:24.5%;border:solid black 1px;color:red;}
>> .f1 {background-color:#eef;}
>> .f2 {background-color:#fee;}
>> </style>
>>
>> Test<br>
>> <div class='f f1'>A</div>
>> <div class='f f2'>B</div>
>> <div class='f f1'>C</div>
>> <div class='f f2'>D</div>
>> <br>Test
>>
>
> This works better in FF if D is not floated.
>
> With the float on D, it can jump to the next row in a narrow window,
> and push the second test way out to the right!
Hello Iam,
since my posting was about 6 weeks ago,
I hartly know what I wás thinking.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress) |
|
| Back to top |
|
 |  |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
|