using hover

Discussion in 'CSS' started by sudhakararaog, Dec 23, 2009.

  1. #1
    i have 2 divs div1 and div2

    there is an image in div2 and there is a link in div1, by default the image in div2 is hidden and i have used
    #div2 img{
    visibility: hidden; // also i tried display: none;
    }

    when i move the mouse over the link in div1 i want the image in div2 to appear

    following is my code
    #div1 a:hover #div2 img1{
    visibility: hidden; or display: none;
    }

    the image in div2 is not appearing

    without using javascript or jquery can this simple effect be done by using css code

    can someone tell me the correct syntax to show the image

    please advice.

    thanks
     
    sudhakararaog, Dec 23, 2009 IP
  2. jwitt98

    jwitt98 Peon

    Messages:
    145
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I believe you would have to use java script for what you are trying to accomplish with css.
    However, if the link and image are close enough together on the page, you could use the hover property to change the background image. This would take a little bit of creative css trickery.
     
    jwitt98, Dec 23, 2009 IP
  3. Wp-Mod.Com

    Wp-Mod.Com Peon

    Messages:
    381
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    it is very easy , surely it can be done with css , why use to div's one is enough

    like you code may be looks like this

    <div class="blahblah"><a href="http://example.com">Exapmple</a></div>

    CSS
    .blahblah a:hover{
    background: url(link/to/the/image.png)
    }

    or you are looking for some what tooltip type of function
     
    Wp-Mod.Com, Dec 24, 2009 IP
  4. 123funda

    123funda Member

    Messages:
    462
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #4
    it can be don with only one Div, insert image in div one and then a link and do as "Wp-Mod.Com" is saying
     
    123funda, Dec 27, 2009 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #5
    Silly question, but do you even NEED the second div?
     
    deathshadow, Dec 27, 2009 IP
  6. sudhakararaog

    sudhakararaog Member

    Messages:
    73
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6
    i have tried using this method

    .blahblah a:hover{
    background: url(link/to/the/image.png)
    }

    however when i hover i do not see the entire width and height of the image
    i have specified width and height as well which is the images width and height

    .blahblah a:hover{
    background: url(link/to/the/image.png)
    width: 500px;
    height: 300px;
    }
     
    sudhakararaog, Dec 27, 2009 IP
  7. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #7
    Anchor is an inline-level tag so it defaults to display:inline; - you cannot set width and height on display:inline elements. Set it to display:block or display:inline-block;
     
    deathshadow, Dec 28, 2009 IP
  8. Wp-Mod.Com

    Wp-Mod.Com Peon

    Messages:
    381
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #8
    you have to specify the width for element with out hover means the links
     
    Wp-Mod.Com, Dec 29, 2009 IP