Show hidden text on hover (CSS)

前端 未结 1 748
眼角桃花
眼角桃花 2021-01-15 08:59

I have tried for a while now to show some text on :hover, is anyone able to explain it for me?

I tried:

#DivForHoverItem:hover #HiddenTe         


        
1条回答
  •  粉色の甜心
    2021-01-15 09:12

    The #HiddenText element has to be inside the #DivForHoverItem element if you want to achieve this with CSS. Try something like this:

    #DivForHoverItem {
        /*just so we can see it*/
        height: 50px;
        width: 300px;
        background-color: red;
    }
    
    #HiddenText {
        display: none;
    }
    
    #DivForHoverItem:hover #HiddenText {
        display:block;
    }

    Hidden text

    jsfiddle link for convenience

    0 讨论(0)
提交回复
热议问题