Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation referencing style.margin-top

    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):

    Code:
    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):
    Code:
    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);
    	}
    }

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try using the camelCase convention: style.marginTop

  • #3
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    flippenCodingPractices

    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

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by daiwa
    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...

  • #5
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    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).
    Last edited by Bill Posters; 08-31-2005 at 03:36 PM.

  • #6
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Bill Posters
    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...]
    Last edited by brothercake; 09-02-2005 at 08:46 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •