Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS overwrite background.css code

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #43935
    intodesign
    Participant

    Regarding to my question here that has been solved:
    https://css-tricks.com/forums/discussion/23934/change-body-background-every-10-sec#Item_10

    $(function() {
    var body = $(‘body’);
    var backgrounds = new Array(
    ‘url(image1.jpg)’,
    ‘url(image2.jpg)’
    );
    var current = 0;

    function nextBackground() {
    body.css(
    ‘background’,
    backgrounds[current = ++current % backgrounds.length]
    );

    setTimeout(nextBackground, 10000);
    }
    setTimeout(nextBackground, 10000);
    body.css(‘background’, backgrounds[0]);
    });

    This code working fine, but if you check the value that i get on FIREBUG
    i guess it gives me the default properties:

    background: url(“image1.jpg”) repeat scroll 0% 0% transparent;

    and i would like to overwrite these properties to

    background: url(“image1.jpg”) no-repeat fixed center center transparent;

    I hope it’s clear what i’m asking, do you have any idea how can i make that?

    #130903
    pixelgrid
    Participant

    using shorthand background declarations should be fine(dont know exactly browser support)

    change

    body.css(
    ‘background’,
    backgrounds[current = ++current % backgrounds.length]
    );

    to

    body.css(
    ‘background’,
    backgrounds[current = ++current % backgrounds.length]+’ no-repeat fixed center center’
    );

    otherwise change each attribute one by one . jquery css function accepts an object too

    #130905
    intodesign
    Participant

    Thanks

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.