View Full Version : Layer's problems

Jul 10th, 2002, 10:07 AM
I would like to know how I can make in Dreamweaver a layer to be fix in the page...not to change his position when I change the resolution of the computer ?

And, how I can make a layer possible for me to move with the mouse...where I want into my web page?

Jul 10th, 2002, 12:58 PM
I think this would do what you want

<div align="center" id="LayerName"
style="HEIGHT: 100px; LEFT: 10px; POSITION: absolute; TOP: 140px; VISIBILITY: hidden; WIDTH: 100%; Z-INDEX: 3">

Anyone feel free to correct me if I am wrong.

As for moving a layer I'd need to have a think about that.

Jul 10th, 2002, 03:33 PM
Think javaScript when you want things to move around.

You want a layer styled with position:absolute and whatever top and left values you wish to start with. You want to know when the mouse is inside the specified area with an onMouseOver() eventhandler. You want to capture the mouse's X and Y coordinates with an onMouseDown() event handler, and you want to capture the mouse's relative movement and transfer that to the left and top values of the layer. Note, you don't want to duplicate the mouse's coordinates, simply the relative change. Mouse moves 10 pixels to the top and 15 to the right, then the new values for the layer would be top=top-10; left = left+15. The specifics of the implementation would be determined by the design and what other layers are on your page. You might also want to change the z-index of the dragged layer to an arbitrarily large value to prevent it from being hidden behind other elements. This isn't a javascript forum, but there's a lot of overlap since your scripts are actually modifying the CSS settings of your layer.

If you're using Dreamweaver, read up on the actions, or check the Macromedia site. This is the kind of basic function that would certainly be available.

Jul 10th, 2002, 06:38 PM
<div style="position: fixed; left: 15px; bottom: 15px;">
Content always in lower left corner

Of course, that only works in the most standard compliant browsers, such as NS6.1+ (any relatively recent Gecko build too), Opera 6, etc.

Take a look at DynamicDrive for some always in one spot scripts.