SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2006
    Posts
    412
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Centering first Div

    Hi Chaps

    Im using the JS scrollto scripts and added a bit to centralise the divs...one thing that im having problems with is the position of the first div (being floated to the left rather than centralised).

    Ive done a forum search and added

    Code:
    $(function(){
        $('#home').css({
            left: $(window).width() / 2 - $('#home').width() / 2
        });
    });
    Oh, one thing that i noticed, unusually, it works fine in IE7 ( i was looking via mozilla)

    but i cant get it to work. The ironic thing is that it was working this morning, now i cant undertand how ive, ...well, broke it!

    The file can be viewed here (click on the menu with the black background for other divs)

    Thanks in advance
    Last edited by barney0o0; Mar 19, 2009 at 11:49. Reason: update: I just noticed that it works in IE7 (i was looking via mozilla)

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Link is broken. Why don't you just use normal CSS to centre it, i.e. stop floating it?

  3. #3
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Raffles, he seems to be using JavaScript “roll-to” effects – basically stuff like jQuery to achieve animation effects on a page layout (possibly single page).

  4. #4
    SitePoint Evangelist
    Join Date
    Mar 2006
    Posts
    412
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey folks, sorry, the page can be found here ( changed it last night)

    Yes, im doing a single page layout for one section of the site.

    If you have a look, maybe you can see the glowing mistakes!

    Ive noticed that the first div centers in opera and ie, but in mozilla it fails....however occasionally locally it works in mozilla, upon refresh the first divs floats to the left again...

    Thanks again in advance


Bookmarks

Posting Permissions

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