3 replies [Last post]
joseek
joseek's picture
User offline. Last seen 1 year 24 weeks ago. Offline
newbie
Timezone: GMT+4
Joined: 2010-08-20
Posts: 1
Points: 2

Hello, everyone!
I have a question about moving divs that are inline elements.
See the attached image, there for example 2 strings of inline divs, is there a way to change their positions by calling any function to make them exchange positions among each other? Or if they need to have not inline display property, what's the best way to make them behave like inline?
inline_divs.gif

Every advice is appreciated!
Thanks in advance.

Ed Seedhouse
Ed Seedhouse's picture
User offline. Last seen 3 weeks 1 day ago. Offline
rank Guru
Guru
Timezone: GMT-8
Joined: 2005-12-14
Posts: 3544
Points: 643

A DIV is never an inline

A DIV is never an inline element. It is a block element by definition, and "Inline DIV" is a contradiction in terms.

You can of course change the rendering mode to inline with a simple CSS rule, but that doesn't make the DIV an inline element, but rather a block element disguised as inline. But it's probably not the best thing to do.

Do you understand the difference between inline and block elements? Why would you use a DIV for that effect in the first place when, if you really need a semantically neutral inline element, SPAN is the appropriate element?

Without seeing your actual code, as the site posting guidlines ask, it's hard to give you any decent advice. What you should actually use is a semantic element that describes that content. It looks vaguely like a list, and that might be the best practice. However without seeing the page it is impossible to really say.

Er, you have read the posting guidlines, haven't you? Smile

Ed Seedhouse

Posting Guidelines

High on a hill, in Wrangellia.

Tyssen
Tyssen's picture
User offline. Last seen 1 day 6 hours ago. Offline
rank Moderator
Moderator
Timezone: GMT+10
Joined: 2004-05-01
Posts: 8123
Points: 1302

joseek wrote: is there a way

joseek wrote:

is there a way to change their positions by calling any function to make them exchange positions among each other?

I don't really understand what that means but I'm going to say 'no'.

joseek wrote:

Or if they need to have not inline display property, what's the best way to make them behave like inline?

Either float:left, display: inline or display: inline-block.

How to get help
Post a link. If you can't post a link, jsFiddle it.
My blog | My older articles | CSS Reference

jon19870
jon19870's picture
User offline. Last seen 22 weeks 6 days ago. Offline
rank Enthusiast
Enthusiast
Timezone: GMT+1
Joined: 2007-01-05
Posts: 195
Points: 194

JavaScript would be required

JavaScript would be required for moving the divs around.