Question

This hovering idea works fine when i use it saperately on a small single page, but when I use it on my project, its not working. Here's the code:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="WebRole1.WebForm4" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">


<style>
#sel>a: hover #span1 {
    display: block;
}

#sel>a{
    position: relative;
    color: rgba(255,255,255,1);
    text-decoration: none;
    background-color: rgb(0, 148, 255);
    font-family: 'Yanone Kaffeesatz';
    font-weight: 700;
    font-size: 3em;
    display: block;
    padding: 4px;
    -webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;
-webkit-box-shadow: 3px 10px 55px 14px rgba(51,39,51,1);
-moz-box-shadow: 3px 10px 55px 14px rgba(51,39,51,1);
box-shadow: 3px 10px 55px 14px rgba(51,39,51,1);
    margin: 100px auto;
    width: 160px;
    text-align: center;
        -webkit-transition: all .1s ease;
    -moz-transition: all .1s ease;
    -ms-transition: all .1s ease;
    -o-transition: all .1s ease;
    transition: all .1s ease;
                top: 0px;
                left: -1px;
            }
#sel>a:active {
    -webkit-box-shadow: 0px 3px 0px rgba(219,31,5,1), 0px 3px 6px rgba(0,0,0,.9);
    -moz-box-shadow: 0px 3px 0px rgba(219,31,5,1), 0px 3px 6px rgba(0,0,0,.9);
    box-shadow: 0px 3px 0px rgba(219,31,5,1), 0px 3px 6px rgba(0,0,0,.9);
    position: relative;
    top: 6px;
}
</style>

<div id="sel">
            <a href="webform1.aspx" >Private Album!</a>    
            <a href="webform3.aspx">Public Album!</a> 
</div>

<span id="span1">
    Apple.
    </span>
</asp:Content>

What i want is whenever I hover to, private album or public album, it should show Apple. Otherwise, nothing. But it keeps showing Apple on the lower left corner of the screen. What is wrong?

Était-ce utile?

La solution

Your CSS selector is wrong.

Instead of this:

#sel > a:hover #span1

use this

#sel > a:hover + #span1

Selectors reference: http://www.w3schools.com/cssref/css_selectors.asp

And the "Apple" is still visible, because you should hide it from the beginning like this:

#span1 {display: none;}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top