...

View Full Version : referencing style.margin-top



daiwa
08-30-2005, 05:06 PM
Now i have a simple page where i have a bunch of thumbnails inside a div they scroll via 2 images. the problem is i can make the whole div box scroll around by changing references to margin.top with just .top. I have tried calling style.marging-top and other variations to no avail. Is there something i'm missing? of course if you have another way of implementing this go right ahead. I have started babling with the idea of making hte div container under (z index) the rest but it still appears at the bottom of the page and i would need to use something to cover it up (not really pretty and i like restircting its height and just moving the stuff inside the div better than moving the div itself)

does not work (simplified version without border checking and such):



function moveup(){
top = document.getElementById('mover').style.margin.top;
topnum = parseInt(top);
height = document.getElementById('mover').style.height;
heightnum = parseInt(height);
test = heightnum + topnum;
topnum = topnum - increment;
document.getElementById('mover').style.margin.top = topnum;
setTimeout("moveup()", speed);
}


works (full version with border checking, but only moves the whole div around and therefore causes problems all over the page):


function moveup(){
top = document.getElementById('mover').style.top;
topnum = parseInt(top);
height = document.getElementById('mover').style.height;
heightnum = parseInt(height);
test = heightnum + topnum;
if (maxbottom > test){
up = false;
}
if (up){
topnum = topnum - increment;
document.getElementById('mover').style.top = topnum;
setTimeout("moveup()", speed);
}
}

Willy Duitt
08-31-2005, 03:22 AM
Try using the camelCase convention: style.marginTop

daiwa
08-31-2005, 01:08 PM
argh thanks, when will they standardize on anything if its margin-top in the css it should be margin-top or it should be marginTop in the css whatever but make it standard.

thanks

Willy Duitt
08-31-2005, 03:47 PM
argh thanks, when will they standardize on anything if its margin-top in the css it should be margin-top or it should be marginTop in the css whatever but make it standard.

thanks

CamelCasing properties that contain a hyphen is a standard...

Bill Posters
08-31-2005, 04:30 PM
I think the point daiwa is making is that it would be better if the naming convention for css properties in css matched the naming convention for addressing css properties in js.
i.e. one naming convention ('standard') would be preferable to two - which is what we currently have.

I think it's a fair point.

The fact that we have two smacks of the left hand not being totally aware of what the right hand is doing. A little more overview might have produced a simpler, more portable standard (regarding the naming and addressing of style properties in css and js).

daiwa
08-31-2005, 05:40 PM
I think the point daiwa is making is that it would be better if the naming convention for css properties in css matched the naming convention for addressing css properties in js.
i.e. one naming convention ('standard') would be preferable to two - which is what we currently have.

Thank you Bill,

being ESL my point is sometimes lost or garbled in translation. what i meant is i can understand between PHP and Java or C++ and al being different function naming conventions (example PHP depriciated its camelCase for underscore_syndrome) and i'm not against that i'm just saying that something so tightly integrated as JS and CSS should at the very least refer to things in the same way. I'm not advocating that Camel case is bad or that changing hyphens to Camel case or changing hyphens to underscore i'm jsut saying the W3C could/should make it standard that style:"marginTop:25px" is Javascript style.marginTop or the other way around.

[edited by brothercake to avoid a third flame up of this thread...]



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum