DIV disappears with Relative Positioning

D

Don Dean

Hi All,
I've found a new enhancement in FP2003, my DIV element disappears when I set
the Position to Relative?

I created a Layer on my web page and set it up with borders and colors the
way I wanted it. It contains only text.

I wanted it to stay at a certain point relative to my page text, so when I
was done with it, I then set the Position to Relative. I know that it ceases
being a Layer when you do this and it becomes strictly a DIV element. That's
fine with me and it looks OK in Design, but when I go to Preview mode or use
IE, it can't be seen. There's just a blank space where I expected the
element to be.

If I go to the code and change the Positioning back to Absolute, then it
reappears, although not exactly where I want it, since it looses it's place
with respect to the other text on the page.

What's the deal, why does it disappear?
 
M

Murray

What's the deal, why does it disappear?

I dunno. What's the URL.

You know how relative positioning works, right?
 
M

Murray

And, why did you start with an absolutely positioned div in the first place?
Just for convenience?
 
D

Don Dean

Hi Murray,
yes, for convenience. With a right mouse click, you can go right to Layer
Properties.
Am I missing something, is there a way to edit DIV elements with drop down
menus in FP??

This is the same web site I was working on when you helped me out with the
custom bullet problems, it's not published yet. The more I work on it, the
bigger it gets.

I've included the DIV code from the page:

<div style="position: absolute; width: 455px; height: 65px; z-index: 1;
left: 240px; top: 1840px; border-style: outset; border-width: 4px;
padding-left: 8px; padding-right: 8px; padding-top: 6px; padding-bottom: 6px;
background-color: #FFCCFF" id="layer1"><b>BEWARE:</b> Not all Web Browsers
will display your site the way you designed it and this might require you to
go back and make some changes based on the results you see.</div>

I know that Relative Position in Design mode shows the DIV element where I
want it, basically in the center (left to right) of the page and as I add
text above it, it will move down with the text, i.e. it stays relative to the
same position in the text. Is there something here that I don't know about??
--
Don
*********


Murray said:
And, why did you start with an absolutely positioned div in the first place?
Just for convenience?
 
S

Stefan B Rusynko

Did you stop to think that when you make it relative and assign a position like left: 240px; top: 1840px; it may not be anywhere on
the user screen?
- if it is in say a table cell on the right of the page if will "disappear" due to your left/top
(even absolute positioning puts it way down the page due to the top 1840!)

Just try this code in a new page
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#FFFFFF" id="table1">
<tr><td nowrap>cell 1 row1</td>
<td>cell 2 row 1
<div style="position: relative; width: 455px; height: 65px; z-index: 1; left: 240px; top: 1840px; border-style: outset;
border-width: 4px; padding-left: 8px; padding-right: 8px; padding-top: 6px; padding-bottom: 6px;
background-color: #FFCCFF" id="layer1">
<b>BEWARE:</b> Not all Web Browsers will display your site the way you designed it and this might require you to go back and
make some changes based on the results you see.</div>
</td></tr><tr> <td nowrap>cell 1 row2</td><td>cell 2 row 2</td></tr> </table>
</div>





| Hi Murray,
| yes, for convenience. With a right mouse click, you can go right to Layer
| Properties.
| Am I missing something, is there a way to edit DIV elements with drop down
| menus in FP??
|
| This is the same web site I was working on when you helped me out with the
| custom bullet problems, it's not published yet. The more I work on it, the
| bigger it gets.
|
| I've included the DIV code from the page:
|
| <div style="position: absolute; width: 455px; height: 65px; z-index: 1;
| left: 240px; top: 1840px; border-style: outset; border-width: 4px;
| padding-left: 8px; padding-right: 8px; padding-top: 6px; padding-bottom: 6px;
| background-color: #FFCCFF" id="layer1"><b>BEWARE:</b> Not all Web Browsers
| will display your site the way you designed it and this might require you to
| go back and make some changes based on the results you see.</div>
|
| I know that Relative Position in Design mode shows the DIV element where I
| want it, basically in the center (left to right) of the page and as I add
| text above it, it will move down with the text, i.e. it stays relative to the
| same position in the text. Is there something here that I don't know about??
| --
| Don
| *********
|
|
| "Murray" wrote:
|
| > And, why did you start with an absolutely positioned div in the first place?
| > Just for convenience?
| > --
| > Murray
| > ============
| >
| > | > > Hi All,
| > > I've found a new enhancement in FP2003, my DIV element disappears when I
| > > set
| > > the Position to Relative?
| > >
| > > I created a Layer on my web page and set it up with borders and colors the
| > > way I wanted it. It contains only text.
| > >
| > > I wanted it to stay at a certain point relative to my page text, so when I
| > > was done with it, I then set the Position to Relative. I know that it
| > > ceases
| > > being a Layer when you do this and it becomes strictly a DIV element.
| > > That's
| > > fine with me and it looks OK in Design, but when I go to Preview mode or
| > > use
| > > IE, it can't be seen. There's just a blank space where I expected the
| > > element to be.
| > >
| > > If I go to the code and change the Positioning back to Absolute, then it
| > > reappears, although not exactly where I want it, since it looses it's
| > > place
| > > with respect to the other text on the page.
| > >
| > > What's the deal, why does it disappear?
| > > --
| > > Don
| > > *********
| >
| >
| >
 
D

Don Dean

Thanks guys, I've figured something out.
I originally thought that the only way to create a DIV element (without hand
coding it) was to use the "Insert / Layer" functions. That's the reason I
created a Layer, then tried to set it's position as Relative.

I now see that you can position your cursor and then go to "Format /
Positiion" and define the values for a DIV element. And if I set it's
position as Relative, everything works just fine and it displays OK.

I see that there are some diferences in the DIV code when a DIV element is
created this way as opposed to using the Layer function. I suspect I caused
a problem by making an Absolute positioned layer, then changing the position
to Relative. I don't know what the problem was, but at least I know how to
create a Relative DIV element now.

Thanks for your consideration.
 
M

Murray

I don't know what the problem was, but at least I know how to
create a Relative DIV element now.

The problem is the position values. When you position the layer, that
offset is *usually* calculated from the upper left-hand corner of the page
(unless the layer is nested within some other positioned element). When you
then change position:absolute to position:relative, the position offsets
refer to where that div would have fallen in the absence of any offsets.
Unless that div is the very first thing on the page, that will never
*usually* be the upper left-hand corner.

That's why I asked if you understood how relative positioning works....

This may help you understand positioning a bit -

There are 4 different types of positioning:
Absolute
Relative
Fixed
Static

Here is a brief explanation of each kind....

Position:absolute
-----------------------
This does several things -
1. It 'removes' the element from the flow of the code on the­ page so that
it can no longer influence the size or position of any other pa­ge element
(except for those contained within it, of course).

2. The absolutely positioned element takes its position from the position of
its closest PA­RENT *positioned*
element - in the absence of any explicitly positioned parent, this will
default to the <body> tag, which is always positioned ­at 0,0 in the browser
viewport.

This means that it doesn't matter where in the HTML code the laye­r's code
appears (between <body> and </body>), its location on the screen will not
change. Furthe­rmore, the
space in which this element would have appeared were it not positi­oned is
not
preserved on the screen. In other words, absolutely positioned elements
don't take up any space on the page. In fact, they FLOAT over the page.

Position:relative
----------------------
In contrast to absolute positioning, a relatively positioned page element is
*not* removed from t­he flow of the
code on the page, so it will use the spot where it would have­ appeared
based
on its position in the code as its zero point reference. If­ you then
supply top, right, bottom, or left positions to the style for this ­element,
those
values will be used as offsets from its zero point.

This means that it DOES matter where in the code the relativ­ely positioned
element appears, as it will be positioned in that location (­factoring in
the offsets) on the screen. Furthermore, the space where this e­lement
would
have appeared is preserved in the display, and can therefore­ affect the
placement of succeeding elements. This means that the taller a relatively
positioned element is, the more space it forces on the page.

Position:static
-------------------
As with relative position, static positions also "go with ­the flow". An
element with a static position cannot have values for offset­s (top, right,
left, bottom) or if it has them, they will be ignored. Unless explicitly
positioned, all div elements default to static positioning.

Position:fixed
------------------
A page element with this style will not scroll as the page c­ontent scrolls.
Support for this in elements other than page backgrounds is ­quirky

There are two other things you need to know:

1. ANY page element can be positioned - paragraphs, tables, images, lists,
etc.
2. The <div> tag is a BLOCK level tag. This means that if it is not
positioned or explicitly styled otherwise, a) it will always begin on a new
line on the screen, and b) it will always force content to a new line below
it, and c) it will always take up the entire width of its container (i.e.,
width:100%).

You can see a good example of the essential difference between absolute and
relative positioning here -

http://www.great-web-sights.com/g_layersdemo.asp
 
D

Don Dean

Thanks Murray for taking the time to spell this out.

Your explaination really clears things up.

I'm still learning things in FP and sometime you don't even know how to ask
the right question because you don't know what you don't know.
 
M

Murray

You're welcome, Don!

--
Murray
============

Don Dean said:
Thanks Murray for taking the time to spell this out.

Your explaination really clears things up.

I'm still learning things in FP and sometime you don't even know how to
ask
the right question because you don't know what you don't know.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top