tags:

views:

45

answers:

2

hi,

I'm using css to edit the content of a page (NB. I cannot edit html code).

I have 2 columns div1, div2. Each columns have several children (containing text). If the block has 2 or more lines of text all successive content is automatically moved down.

I need to move a chidlren from the first column to the second one, in the middle. I was considering to use absolute positioning but then I realize how children are not anymore moving down as the number of text lines increases.

How can I solve this ?

<div id=div1>
  <div> blabla </div>
  <div> blabla </div>
  <div> blabla </div>
</div>

<div id=div2>
  <div> blabla </div>
  <div> blabla </div>
  <div> blabla </div>
</div>

thanks

A: 

You can't do this in pure CSS 2. (Well you sometimes can, depending on your scenario, but only with awful hacks involving absolute positioning and such.)

CSS 3 has columns but they are not widely enough supported yet supported by all modern browsers except IE.

There are several jQuery based attempts like this one that add column functionality but of course, they need JavaScript enabled.

Pekka
To the contrary, all the modern browsers support columns except IE, of course, and Opera. I've forgotten where Opera is on this and I don't know if IE9 claims it will support it.
Rob
@Rob - They *almost* support columns, FireFox has *full* support, as well as strict IE8, all the others aren't quite there, though they have a working (but not *complete*) implementation.
Nick Craver
@Rob if you can afford not to support IE, that's fine, but it's usually not an option.
Pekka
@Pekka, who said anything about not supporting IE?
Rob
@Rob you contradicted my statement "they are not widely enough supported yet" by saying "to the contrary, all the modern browsers support columns..." so I assumed you do not deem IE as a browser worth supporting, which is a widely spread view but a mistake IMO.
Pekka
Rob
@Pekka, my thoughts are this: If you have 5 major browsers, and 4 support something, then it is widely supported.
Rob
@Rob but that's not widely enough if it'll look like crap in IE, is it?
Pekka
@Pekka - It doesn't matter if it works in IE or not. The point is, the majority of browsers support multi-column.
Rob
@Rob of course it matters. What good is a CSS 3 multi-column layout if I have to add three tons of workarounds to make it work in IE? Still, your point is taken, they are widely supported except for IE which is different from "not widely supported." I edited by answer accordingly.
Pekka
@Pekka - It matters but doesn't change the point I'm making. I don't want anyone to think they can't use it because it's not widely supported by browsers. It IS widely supported by browsers but, if you don't want to dumb down your page for IE or don't want to do the usual hacking needed to make things work in IE, then skip it. As usual, this is an IE issue not an overall browser support issue.
Rob
A: 

It is not possible in HTML/CSS, and I cannot think of any layout engine that allows that. Your wish is so strange that you may need to rethink that. Your readers may misunderstand the result even if you manage to make it possible.

The rules of element positioning are more or less the same everywhere. When element positions itself, it can use as a framework: page, column, parent (or one of its parents), current position (previous sibling) and that is it. Each peace of content either resides in its own part of the document and finds its place there, or leaves altogether and positions relative to the page. There is no emigration in layout.

buti-oxa