Welcome to WebmasterWorld Guest from 3.93.75.242

Forum Moderators: not2easy

Message Too Old, No Replies

Having a movable div that floats

     
1:50 pm on Mar 19, 2013 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 15, 2007
posts:620
votes: 2


I'm not exactly sure how to explain this. Let's say I have a 250x250x div (that holds an ad), that I currently have at the top of the page.

What I want to do is have more flexibility so that I can change where in the page (vertically) it appears via css to test various locations. I've been trying to do this using various positioning options, but all I can get is the div to sit on top of the larger text block, rather than it floating and the large text block making room for it.

I don't want to move the code itself. I just want to be able to make it appear lower or higher on the page simply by altering the css.

This should be possible? I've worked on this over the last while on and off for months (ok, it's a learning experience), but I simply can't get it.

Can anyone point me in the right direction?
3:39 pm on Mar 19, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2003
posts:960
votes: 34


Sorry, but you can't eliminate the relationship between where your content resides within an HTML document and its effect on how adjacent content is displayed using CSS alone. You could, however, modify the document itself with JavaScript and move selected sections of HTML from one location to another.
6:47 pm on Mar 19, 2013 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 15, 2007
posts:620
votes: 2


Thanks Rainborick, at least I can stop struggling with doing it that way. Since I'm not a javascript programmer, any idea if there's some code I can scrounge to try to modify.

The task, on the surface of it is simple -- to have a block that the main text will wrap around, and to be able to move the block occasionally with respect to how far down the page it is displayed. It's primarily to get some ads from the top to the middle, without actually doing the whole thing manually for thousands of pages.
10:13 pm on Mar 19, 2013 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15936
votes: 889


I don't want to move the code itself. I just want to be able to make it appear lower or higher on the page simply by altering the css.

Floats by definition display as soon as they can. Either right away, or after any preceding floats are finished; that's the only variable. So you can only move it by physically moving the code.

It may help to remember that HTML+CSS isn't a programming language. It's "only" a fairly sophisticated word processor.