Show button on hover only

前端 未结 4 1948
后悔当初
后悔当初 2021-02-19 00:36

I\'ve read around and tried other solutions to my problem but none seem to work.

I have 3 images, each within their own 4-column div. I have a css transition set up so t

4条回答
  •  自闭症患者
    2021-02-19 00:56

    You could use a simple img:hover + .button to select the link (the + selects the next element if it matches the .button selector)

    .button {
      display: none;
    }
    img:hover + .button {
      display: inline-block;
    }

    Alternatively if the button isn't over the image, you could use :hover on a wrapper element, which avoids the problem of the image no longer being hovered when you want to click the button (the button would disappear when you try to click it, as seen in the above example)

    .button {
      display: none;
    }
    .wrapper:hover img {
      /* Change the filter in here */
    }
    .wrapper:hover .button {
      display: inline-block;
    }

提交回复
热议问题