SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 33 of 33
  1. #26
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeag i saw that but i need something like that but the bg img is CSS

    There its javascript

  2. #27
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,353
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by chawchaw View Post
    Yeag i saw that but i need something like that but the bg img is CSS

    There its javascript
    I've no idea what you just said

    Please explain what you require in detail and not in some cryptic sentence and we'll try to help.

    I'll have a guess at what you meant and if you want to change images randomly then it can't be done by css alone as css does not do dynamic changes as that is the realm of scripting.

    The JS simply supplies a random url for the background property to replace the default.

  3. #28
    SitePoint Member
    Join Date
    Aug 2009
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Paul O'B View Post
    You have 5 images so you need to change the variable to 5.
    Code:
    var numimages=5; 
    I assume this code isn't present in your actual script:
    Code:
     2:27 AM 8/17/2009
    Get rid of it if it is.

    If it's still not working provide a link or the full html/css.


    hey paul.. thank you so much for your help . this script is awesome. I LOVE YOU hahah.. thanks again .

    EDIT: my images are bigger .. how do make it so that it fits to the div box i have ? some images are big in size, and its just showing half or portion of it.

  4. #29
    SitePoint Member
    Join Date
    Aug 2009
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey this probably not related to this thread.

    I have a problem when i click on the link 'home' or refresh in Windows Internet Explorer it takes me to the main page. but when i click i can see something flashing at the background. but in Firefox it works fine. what could be the issue??

    any help please.

  5. #30
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,353
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    EDIT: my images are bigger .. how do make it so that it fits to the div box i have
    You would need to set the container that the images are displayed in to the height of the largest image you are using.

    e.g.
    Code:
    #banner {
     height:100px;/* adjust height to size of largest image */
     border:1px solid #000;
     background:#ffffcc url(images/pmoblogo5.jpg) no-repeat center center;
    }
    As we are using background images then they take up no space on the page and the element would need to have a height pre-set. Usually with headers and banners you would have the same height images all the time so there is no problem. it may be a bit disconcerting to have different size images unless they are centred in the background.

    If you wanted images in the html then you would need to script it so that the img src is updated instead of the background property.

    Something like this I would guess (but Js isn't my strongpoint so perhaps someone else will jump in).

  6. #31
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,353
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by NewBeee View Post
    hey this probably not related to this thread.

    I have a problem when i click on the link 'home' or refresh in Windows Internet Explorer it takes me to the main page. but when i click i can see something flashing at the background. but in Firefox it works fine. what could be the issue??

    any help please.
    If you are still talking about the image swap then that's probably the default image showing while the other image gets loaded. We'd need to see a link to the page in question.

  7. #32
    SitePoint Member
    Join Date
    Aug 2009
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Paul O'B View Post
    Hi,



    You would need to set the container that the images are displayed in to the height of the largest image you are using.

    e.g.
    [code]
    #banner {
    height:100px;/* adjust height to size of largest image */
    border:1px solid #000;
    background:#ffffcc url(images/pmoblogo5.jpg) no-repeat center center;
    }


    Lets say the DIV box is 200x200 in size, andi got images like 200x200, 400x400, 640x500 in size etc.

    what i want to do is, those pictues to get resized so that it fits in the 200x200 box. but if the picture is smaller than 200x200 ( lets say 50x50) i want that to remain 50x50, just the bigger pictures to get resized. I hope it makes sense

  8. #33
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,353
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    I think you would need to use an image in the html to do that as I'm not sure how you can resize background images other than by clipping them.

    Here is a rough example (that I hope someone here can tidy up ) that sets the image to a max width or height and hopefully maintains some of the aspect ratio.

    http://www.pmob.co.uk/temp/randombgimage5.htm

    The issues I see are that the default image and the resizing are visible for a fraction each time you refresh.

    Hopefully someone else can step in and tidy this up as I'm going back to the CS forum where I belong


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
  •