Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Sep 2007
    Location
    England
    Posts
    3,602
    Tokens
    500

    Latest Awards:

    Default Change a DIV's Background via CSS based on time

    Hey,

    I've got this piece of CSS;

    #header {
    background: url(images/header.png);
    height: 150px;
    width: 900px;
    }

    How do I set it so that between 9PM and 6AM the background for it is images/header1.png (showing moon etc) and otherwise it displays header.png (sunshine etc)

    +rep to all help
    The other day I was in a toilet.
    A voice came from the cubicle next to me: "Hello mate, how are you doing?"
    I didn't want to be rude, so I said, "Not too bad, thanks."
    I heard the voice again. "So, what are you up to?"
    Again I answered, "Just having a quick ****... How about yourself?"
    Then I heard him say "Sorry, mate, I'll have to call you back. I've got some **** in the cubicle next to me answering everything I say."

  2. #2
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Quote Originally Posted by Favourtism View Post
    Hey,

    I've got this piece of CSS;

    #header {
    background: url(images/header.png);
    height: 150px;
    width: 900px;
    }

    How do I set it so that between 9PM and 6AM the background for it is images/header1.png (showing moon etc) and otherwise it displays header.png (sunshine etc)

    +rep to all help
    Youd probably need to use php, ether to generate that bit of css, or as part of the image itself*

    *basically you create a php file that contains the code to include the image you want depending on the time of day. Use a htaccess to make the php interpreter check say, pngs for php, then change the extension of your image file php to png itself "/

    Though easiest method would probably be just to cut the image out of your css and apply it as an inline style using some php inside your page. "/

  3. #3
    Join Date
    Sep 2007
    Location
    England
    Posts
    3,602
    Tokens
    500

    Latest Awards:

    Default

    Right, how do I do that LOL. The only PHP I can do is advertisment/banner random generators etc
    The other day I was in a toilet.
    A voice came from the cubicle next to me: "Hello mate, how are you doing?"
    I didn't want to be rude, so I said, "Not too bad, thanks."
    I heard the voice again. "So, what are you up to?"
    Again I answered, "Just having a quick ****... How about yourself?"
    Then I heard him say "Sorry, mate, I'll have to call you back. I've got some **** in the cubicle next to me answering everything I say."

  4. #4
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    This is my 26th hour awake coming from 2 hours sleep last night so appologise if the code makes no sence

    change your (im guessing div) tag id'd as header to add the style=' stuff ' and php bit below. + remove the background image from the css up top

    Code:
    <div id='header' style='background-image: url(<?php
    
    $time = date('G'); //return current hour (server time)
    
    if($time < 7 || $time > 21) echo 'images/header.png'; // 9;00pm -> 6:00am
    else echo 'images/header1.png'; //7am ->8pm
    
    ?>);'>
    No garentees thats correct / will work, twas off me head and me head has kinda stopped working

  5. #5
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    This is my 26th hour awake coming from 2 hours sleep last night so appologise if the code makes no sence

    change your (im guessing div) tag id'd as header to add the style=' stuff ' and php bit below. + remove the background image from the css up top

    Code:
    <div id='header' style='background-image: url(<?php
    
    $time = date('G'); //return current hour (server time)
    
    if($time < 7 || $time > 21) echo 'images/header.png'; // 9;00pm -> 6:00am
    else echo 'images/header1.png'; //7am ->8pm
    
    ?>);'>
    No garentees thats correct / will work, twas off me head and me head has kinda stopped working

  6. #6
    Join Date
    Sep 2007
    Location
    England
    Posts
    3,602
    Tokens
    500

    Latest Awards:

    Default

    Hey,

    Just remembered that vBulletin Templates do not parse php LOL. Lemme add it as a product and try. THANKYOU
    The other day I was in a toilet.
    A voice came from the cubicle next to me: "Hello mate, how are you doing?"
    I didn't want to be rude, so I said, "Not too bad, thanks."
    I heard the voice again. "So, what are you up to?"
    Again I answered, "Just having a quick ****... How about yourself?"
    Then I heard him say "Sorry, mate, I'll have to call you back. I've got some **** in the cubicle next to me answering everything I say."

  7. #7
    Join Date
    Sep 2007
    Location
    England
    Posts
    3,602
    Tokens
    500

    Latest Awards:

    Default

    Screw that, I'll make it a .php file and then use that as the divs background.

    How do I edit that PHP so that instead of generating the url or header.png, it actually shows it?
    The other day I was in a toilet.
    A voice came from the cubicle next to me: "Hello mate, how are you doing?"
    I didn't want to be rude, so I said, "Not too bad, thanks."
    I heard the voice again. "So, what are you up to?"
    Again I answered, "Just having a quick ****... How about yourself?"
    Then I heard him say "Sorry, mate, I'll have to call you back. I've got some **** in the cubicle next to me answering everything I say."

  8. #8
    Join Date
    Jan 2008
    Posts
    3,711
    Tokens
    100

    Latest Awards:

    Default

    While browsing around searching for a css style switcher, I came along this thing.
    Let me Google and find it again

    EDIT: Check this..
    http://www.katgal.com/2007/03/time-s...er-change.html

  9. #9
    Join Date
    Sep 2007
    Location
    England
    Posts
    3,602
    Tokens
    500

    Latest Awards:

    Default

    Quote Originally Posted by Meti View Post
    While browsing around searching for a css style switcher, I came along this thing.
    Let me Google and find it again

    EDIT: Check this..
    http://www.katgal.com/2007/03/time-s...er-change.html
    Dont really wanna change the whole css though
    The other day I was in a toilet.
    A voice came from the cubicle next to me: "Hello mate, how are you doing?"
    I didn't want to be rude, so I said, "Not too bad, thanks."
    I heard the voice again. "So, what are you up to?"
    Again I answered, "Just having a quick ****... How about yourself?"
    Then I heard him say "Sorry, mate, I'll have to call you back. I've got some **** in the cubicle next to me answering everything I say."

  10. #10
    Join Date
    Jan 2008
    Posts
    3,711
    Tokens
    100

    Latest Awards:

    Default

    You only change the background image...?
    Copy the default.css, and rename it to like "night.css". Then only change the background. And edit the codes given by the KatGal site.

Page 1 of 2 12 LastLast

Posting Permissions

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