Results 1 to 7 of 7

Thread: Hide Image until mouseover?

  1. #1

    Thread Starter
    Hyperactive Member Emo's Avatar
    Join Date
    Jul 2000
    Posts
    428

    Arrow Hide Image until mouseover?

    Is this possible to do? I tried almost everything I could think of but I can't make it so when the page loads a specific picture doesnt show until I move my mouse over it...

    any help would be appreciated!
    -Emo
    -=VB6 Enterprise Edition=-
    -=VC++6Enterprise Edition=-
    «¤E³m°O²™¤»

  2. #2
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    Try putting it inside a layer. I'd use this code to acheive it

    Code:
    <div style="position:absolute; left:20px; top:50px; width:100px; height:100px;" onmouseover="document.getElementById('image1').style.visibility='visible'">
      <img id="image1" name="image1" src="image1.jpg" style="visibility:hidden;">
    </div>
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  3. #3
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    And I think also you can use display rather than visiblity:

    Code:
    <div style="position:absolute; left:20px; top:50px; width:100px; height:100px;" onmouseover="document.getElementById('image1').style.display='block'">
      <img id="image1" name="image1" src="image1.jpg" style="display:none;">
    </div>
    You can also use "inline" rather than "block" if you want the image to stay in the "flow" of the rest of the document.

  4. #4
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    You can also use "inline" rather than "block"
    Yeah, but by default Div is set to block as it is a Block Element. If using inline wouldn't it be better to use Span?
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  5. #5
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Dunno You're probably right, I've never tested it before

  6. #6
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    I could be wrong about this, but, if you use "display: none", then how will you me able to mouse over it? I sugest "visibility".
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  7. #7
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Travis hit the nail on the head.

    You could also use a transparent gif at first, and just do a normal image swap at mouseover.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

Posting Permissions

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



Click Here to Expand Forum to Full Width