Is it possible to make a blurred gradient shadow with CSS?

后端 未结 2 716
执念已碎
执念已碎 2021-02-04 21:22

Here is a shadow:

So I need this to be a shadow which appears on button hover. I know its css but I didn\'t manage to make any blur:

background         


        
2条回答
  •  被撕碎了的回忆
    2021-02-04 22:21

    You can get this effect in modern browsers using a pseudo element with the same background, and a filter blur applied on it.

    To get compatibility with IE, you can set also a pseudo, and to get the blurred borders use an inset shadow. At least in Chrome, there is a small left over of the border that still can be seen.

    .test {
      margin: 20px;
      background-image: linear-gradient(-90deg, #CF77F3 0%, #009BFF 47%, #2AC9DB 100%);;
      border-radius: 50px;
      display: inline-block;
      height: 100px;
      width: 200px;
      position: relative;
      border: solid 4px black;
    }
    
    #test1:after {
      content: "";
      position: absolute;
      background-image: inherit;
      border-radius: inherit;
      width: inherit;
      height: inherit;
      transform: translate(0px, 20px) scale(1.1);
      z-index: -1;
      filter: blur(14px);
    }
    
    #test2:after {
      content: "";
      position: absolute;
      border-radius: 90px;
      width: 250px;
      height: 150px;
      z-index: -1;
      top: 1px;
      left: -25px;
      background-image: linear-gradient(-90deg, #CF77F3 0%, #009BFF 47%, #2AC9DB 100%);
      box-shadow: inset 0px 0px 25px 18px white;
    }

提交回复
热议问题