Open In App

How to add Box-Shadow to The Clip-Path Object ?

As we all know that we can apply the shadow using the Box-Shadow attribute of CSS, but it is not valid if we apply it on the 
clipped Object using Clip-Path() function of CSS.

Approach:



HTML Code:

Example: In this example, we are implementing the above-explained steps.






<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>
 
<body>
    <div class="main_box">
        <div class="img"></div>
    </div>
</body>
</html>

CSS Code: The following is the content for the “style.css” file used in the above code. CSS is used to give different types of animations and
effects to our HTML page so that it looks interactive to all users. Consider the following points:

Style.css




.main_box {
    filter: drop-shadow(1.25em .75em 0px rgb(150, 223, 150));
}
 
.img {
    border-radius: 1em;
    width: 15em;
    height: 15em;
    clip-path: polygon(75% 0%, 100% 50%, 75% 100%, 0% 100%, 0% 0%);
    background-color: green;
}

Complete Code: Here we will combine the above two sections into one.




<!DOCTYPE html>
<html lang="en">
<head>
  <style>
    .main_box{
        filter: drop-shadow(1.25em .75em 0px rgb(150, 223, 150));
    }
 
    .img{
        border-radius: 1em;
        width: 15em;
        height: 15em;
        clip-path: polygon(75% 0%, 100% 50%,75% 100%,0% 100%,0% 0%);
        background-color: green;
    }
  </style>
</head>
   
<body>
    <div class="main_box">
        <div class="img"></div>
    </div>   
</body>
</html>

Output:


Article Tags :