Using only CSS, show div on hover over

后端 未结 13 1139
时光取名叫无心
时光取名叫无心 2020-11-22 01:58

I would like to show a div when someone hovers over an element, but I would like to do this in CSS and not JavaScript. Do you know how this can be ach

13条回答
  •  再見小時候
    2020-11-22 02:23

    From my testing using this CSS:

    .expandable{
    display: none;
    }
    .expand:hover+.expandable{
    display:inline !important;
    }
    .expandable:hover{
    display:inline !important;
    }
    

    And this HTML:

    expand
    expand

    , it resulted that it does expand using the second , but does not expand using the first one. So if there is a div between the hover target and the hidden div, then it will not work.

提交回复
热议问题