Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
make image display when hover over
Old 04-15-2012, 10:11 AM make image display when hover over
Average Talker

Posts: 23
Trades: 0
I am trying to create a list of links that don't necessarily navigate to anything. But what I want is to hover over the link and make an image appear in the specified area on the page.

I was able to create the ul list, but I can't seem to make the images appear when I hover over the link. I also tried to hide them if you're not hovering over the link.

I'm not sure what I'm doing wrong but its not working. It seems like my ul and a href aren't picking up the css style.

Can someone help me with this please.

Here's my code:
Code:
<!DOCTYPE html>
<html>
 <head>
 <style type="text/css">
 body{
   background:black;
   line-height:140%;
}
 #imgcontainer{
   position:absolute;
   width:300px;
   height:250px;
   border:1px solid blue;
   margin:0 350px;
   z-index:-1;
   }
   
 #links{
   position:absolute;
   z-index:1;
   }
 
#links ul{
 list-style-type:none;
 margin:0;
 padding:0;
}
#links a img{
   display:none;
   }
   
#links a:hover img {
 display: block; 
 position: absolute;
    margin:0 350px;
 z-index:1;
 }
 </style>
 </head>
 <body>
<div id="links">
<ul>
<li><a href="#tips">Red Velvet</a><img src="peanutbuttermini.gif"></li>
<li><a href="#tips">Chocolate City</a><img src="chocolatecity.gif"></li>
</ul>
</div>
<div id="imgcontainer"></div>

 </body>
 </html>
talytech is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-15-2012, 11:23 AM Re: make image display when hover over
chrishirst's Avatar
Defies a Status

Posts: 43,957
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
CSS can only affect elements that are a child of the one (the parent) that the style or pseudo class is being applied to.

So as your hover is applied to the anchor element and the img element is a child of the <li> it won't be working.

So you either need to use adjacent sibling selectors OR apply the hover pseudoclass to the <li>.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to make image display when hover over
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15818 seconds with 11 queries