在div元素内不可单击SVG图标

问题描述 投票:-1回答:1

SVG图标不可在div元素中单击。 Div是可单击的。这是我的CSS:

     &__icon { 
      position: absolute;
      top: 0.1em;
      right: 50%;
      transform: translateX(50%);
      opacity: 0.5;
      width: 2.5em;
      height: 2.5em;

      svg {
        width: 100%;
        height: 100%;
        pointer-events: none;
      }
    }
svg clickable
1个回答
0
投票

找到解决方案,根据https://stackoverflow.com/a/50925509/13568935

Div重叠SVG。在CSS中将z-index:-1设置为DIV或将SVG元素设置为z-index:2。

© www.soinside.com 2019 - 2024. All rights reserved.