Layout: CSS Javascript properties syntax

started by Jwmpc on Jul 10, 2004 — RSS Feed

Jwmpc Jwmpc
Posts: 13

I've been over the "Scripting the Box" feature, which was a great help understanding how javascript can dynamically affect CSS boxes, but I'm a little unclear on how these properties are accessed in a function.

For example the box property of "background" which can have color, position, etc., becomes "backgroundColor" or "backgroundPosition" etc.

If you intended to change the absolute position of a block, would the property be listed as "positionAbsolute"? The intended effect is to have a black box move gradually to the right uncovering elements underneath that can select things. A pseudo-scroll you might call it.

So my first question would be is "positionAbsolute" the correct way to call this property in javascript (ie, mybox.style.positionAbsolute = "50,100"? Or am I hopelessly confusing the syntax?

The second question: Is there is a reference that gives the box property spellings and how they relate between the two? I checked the general CSS and Javascript references, but of course they speak only generally of box properties for either subject, and not how they might relate.

I realize that I might be overthinking this, as exact values imply absolute ones, but if you have some experience with this, I'd appreciate your help. I posted this here, rather than in "scripting" because I don't want to know how to do the scripting, just the translation from CSS to Javascript.

Joe Gillespie Joe Gillespie
Posts: 528

The full explanation of the DOM (Document Object Model) can be found here http://www.mozilla.org/docs/dom/domref/dom_shortTOC.html but for what you are trying to do, you don't need to change the absolute position. The div is set to be absolute in your main CSS definitions, from there, you only need to change the top or left attributes.


function moveBox(x,y)
{
if (document.getElementById)
   {
   var theBox = document.getElementById("box";
   theBox.style.left=x+"px";
   theBox.style.top=y+"px";
   }
}

Jwmpc Jwmpc
Posts: 13

Thanks! That was what I needed to know (on both questions).

Maskodok Eko Maskodok Eko
Posts: 171

TOP SEO | Jasa SEO Profesional

TOP SEO | Jasa SEO Profesional RajaPoker88.com Agen Texas Poker Dan Domino Online Indonesia Terpercaya IDRPoker.COM Agen Texas Poker dan Domino Online Indonesia Terpercaya POKERSTAR88.com Agen Texas Poker Dan Domino Online Indonesia Terpercaya D

You must login to reply