Adding box-shadow to a :after pseudo element

后端 未结 4 1428
猫巷女王i
猫巷女王i 2020-12-29 23:28

I have a div called .testimonial-inner and using the :after pseudo element I have an arrow that sits underneath it pointing down. The problem I\'m

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-29 23:43

    You could add another :pseudo-element, rotate it by 45deg and add box-shadow to it.

    Updated Fiddle

    body {
      background: #eee
    }
    .testimonial-inner {
      background: #fff;
      -webkit-border-radius: 3px;
      -moz-border-radius: 3px;
      border-radius: 3px;
      padding: 30px;
      display: block;
      margin-bottom: 25px;
      position: relative;
      box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.75);
    }
    .testimonial-inner:after {
      top: 100%;
      left: 48px;
      border: solid transparent;
      content: " ";
      height: 0;
      width: 0;
      position: absolute;
      pointer-events: none;
      border-color: rgba(255, 255, 255, 0);
      border-top-color: #fff;
      border-width: 18px;
      margin-left: -18px;
    }
    .testimonial-inner:before {
      content: '';
      position: absolute;
      transform: rotate(45deg);
      width: 36px;
      height: 36px;
      bottom: -12px;
      z-index: -1;
      box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.75);
    }

    Using Facebook was unquestionably the best decision I could possibly have made at the point in my journalistic journey. It enabled me to share my fears, frustrations as well as successes.


    Another approach using svg as a triangle.

    body {
      background: #eee
    }
    .testimonial-wrap {
      position: relative;
    }
    .testimonial-inner {
      background: #fff;
      -webkit-border-radius: 3px;
      -moz-border-radius: 3px;
      border-radius: 3px;
      padding: 30px;
      display: block;
      margin-bottom: 25px;
      position: relative;
      box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.75);
    }
    #triangle {
      position: absolute;
      top: 100%;
      margin-top: -1px;
      left: 50px;
    }

    Using Facebook was unquestionably the best decision I could possibly have made at the point in my journalistic journey. It enabled me to share my fears, frustrations as well as successes.

提交回复
热议问题