Search code examples
cssvisibilityhiddenfont-size

How to make the text hidden in hover


I am creating a menu that each item has a text and in hover an email replaces. So I do not know how to remove the text in hover.

here is my code so far:

#home {
    font: 30px 'LeagueGothicRegular', Arial, sans-serif;
    color: #f9f8cc;
}

#home:hover {
    background:url(style/images/icon/home.png) #FFF;
    background-size: 83px 56px;
}

Solution

  • You can not remove the text with css, but you can make the text invisible, by setting its color to transparent, so your css would be:

    #home:hover {
       color: transparent;
       background:url(style/images/icon/home.png) #FFF; 
       background-size: 83px 56px; 
    }
    

    If you have layout problems with this solution, you could also wrap another div around the text, and then on :hover set the display of the div to none:

    CSS

    #home:hover .yourDivClassThatContainsText {
       display: none;
    }
    

    HTML

    <div id="home">
       <div class="yourDivClassThatContainsText">
          Text Text TExt
       </div>
    </div>