Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Oct 2008
    Location
    Lincolnshire
    Posts
    1,206
    Tokens
    0

    Latest Awards:

    Default Coding a Layout - Help!

    How do you get like, hover over icons. So when you hover over something, the image changes. +rep.

  2. #2
    Join Date
    Apr 2009
    Location
    United Kingdom
    Posts
    1,111
    Tokens
    100

    Latest Awards:

    Default

    #blah
    {
    background-image:url(images/nonhoverimg.gif);
    width:x;
    height:x;
    }

    #blah:hover
    {
    background-image:url(images/hoverimage.gif);
    }

  3. #3
    Join Date
    Oct 2008
    Location
    Lincolnshire
    Posts
    1,206
    Tokens
    0

    Latest Awards:

    Default

    I dont quite understand as im having several hovers what I do
    #text1
    {
    background-image:url(images/nonhoverimg.gif);
    width:x;
    height:x;
    }

    #text:hover
    {
    background-image:url(images/hoverimage.gif);
    }
    #text2
    {
    background-image:url(images/nonhoverimg.gif);
    width:x;
    height:x;
    }

    #text2:hover
    {
    background-image:url(images/hoverimage.gif);
    }


    ?

  4. #4
    Join Date
    Jun 2008
    Location
    England, On a beach somewhere
    Posts
    2,483
    Tokens
    691

    Latest Awards:

    Default

    erm just go to dynamicdrive.com there is loads on there.

  5. #5
    Join Date
    Apr 2009
    Location
    United Kingdom
    Posts
    1,111
    Tokens
    100

    Latest Awards:

    Default

    Quote Originally Posted by Mickword View Post
    erm just go to dynamicdrive.com there is loads on there.
    *** why when it can be done with css.

  6. #6
    Join Date
    Nov 2005
    Posts
    4,486
    Tokens
    921

    Latest Awards:

    Default

    Quote Originally Posted by BoyBetterKnow View Post
    *** why when it can be done with css.
    Agree. CSS is better
    "RETIRED" FROM HABBO(X)

    :¬:

    TOMSPIT / COWLY05


  7. #7
    Join Date
    Oct 2008
    Location
    Lincolnshire
    Posts
    1,206
    Tokens
    0

    Latest Awards:

    Default

    So was what I said right or not? :S

  8. #8
    Join Date
    Apr 2008
    Location
    North West, UK.
    Posts
    1,007
    Tokens
    529

    Latest Awards:

    Default

    CSS is better, but this person is quiet blatently a 'noob' at coding.

    If you give me your MSN, I'll talk you through it and most likely help you with other stuff :}

  9. #9
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    Javascript and css do the same apart from you css is less code...

    EDIT:

    Heres a javascript version:

    swap.js
    Code:
    function swap(el,which) {
      el.src=el.getAttribute(which || "origsrc");
    }
    
    function swapSetup() {
      var x = document.getElementsByTagName("img");
      for (var i=0;i<x.length;i++){
        var oversrc = x[i].getAttribute("oversrc");
        if (!oversrc) continue;
    
        x[i].oversrc_img = new Image();
        x[i].oversrc_img.src=oversrc;
    
        x[i].onmouseover = new Function("swap(this,'oversrc');");
        x[i].onmouseout = new Function("swap(this);");
    
        x[i].setAttribute("origsrc",x[i].src);
      }
    }
    
    var PreswapOnload =(window.onload)? window.onload : function(){};
    window.onload = function(){PreswapOnload(); swapSetup();}
    Put this in the head of your page:
    Code:
    <script type="text/javascript" src="swap.js"></script>
    And to make your images swap use this for your image code:
    Code:
    <img src="imgs/nav/homepage.png" width="59" height="50" border="0" oversrc="imgs/nav/homepage_over.png" />
    Hope i helped .

    Lew.
    Last edited by LMS16; 26-09-2009 at 08:27 AM.

  10. #10
    Join Date
    Nov 2006
    Location
    Narrich
    Posts
    5,687
    Tokens
    0
    Habbo
    Jamesy...

    Latest Awards:

    Default

    Quote Originally Posted by Lewiie15 View Post
    Javascript and css do the same apart from you css is less code...

    EDIT:

    Heres a javascript version:

    swap.js
    Code:
    function swap(el,which) {
      el.src=el.getAttribute(which || "origsrc");
    }
    
    function swapSetup() {
      var x = document.getElementsByTagName("img");
      for (var i=0;i<x.length;i++){
        var oversrc = x[i].getAttribute("oversrc");
        if (!oversrc) continue;
    
        x[i].oversrc_img = new Image();
        x[i].oversrc_img.src=oversrc;
    
        x[i].onmouseover = new Function("swap(this,'oversrc');");
        x[i].onmouseout = new Function("swap(this);");
    
        x[i].setAttribute("origsrc",x[i].src);
      }
    }
    
    var PreswapOnload =(window.onload)? window.onload : function(){};
    window.onload = function(){PreswapOnload(); swapSetup();}
    Put this in the head of your page:
    Code:
    <script type="text/javascript" src="swap.js"></script>
    And to make your images swap use this for your image code:
    Code:
    <img src="imgs/nav/homepage.png" width="59" height="50" border="0" oversrc="imgs/nav/homepage_over.png" />
    Hope i helped .

    Lew.
    But what if javascript is disabled on a browser?

    Quote Originally Posted by Serant View Post
    CSS is better, but this person is quiet blatently a 'noob' at coding.

    If you give me your MSN, I'll talk you through it and most likely help you with other stuff :}
    If he's a noob at coding then its best to teach him how to do it right rather than give him bad habits now.
    Ex-janitor. Might pop in from time to time, otherwise you can grab all my information from http://jamesy.me.uk/

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
  •