JavaScript transition with the display property?

前端 未结 3 1198
粉色の甜心
粉色の甜心 2021-01-28 01:54

Can I make a certain element fade in when I hover over another one, and make it fade out when my mouse isn\'t on the element anymore?

I tried adding a transition

3条回答
  •  感情败类
    2021-01-28 02:49

    Here's a pure css solution for your specific html:

    fiddle

    html

    for the css I used opacity instead of display and added the following:

    css

    #button:hover ~ #menu,
    #menu:hover {
        opacity:1;
        height:100px;
    }
    

提交回复
热议问题