I want the clip path content to be visible outside the clip path area

71 views Asked by At

The content inside the clip-path container is not visible outside the `clip-path region.

I tried applying positioning property to the container. I applied relative positioning to the outer container containing the clip path and absolute to the container with the content, I also added a larger z-index to the content div expecting the content to be visible.

<link href="https://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css" rel="stylesheet">

<div class="bg-[#EDF4F9]">
  <div class='hero-section z-30 h-100v bg-blue-500 text-white p-4 text-left flex flex-col justify-center items-start h-[550px] md:h-[580px] lg:h-screen' style="clip-path: polygon(0 0, 45% 0, 10% 100%, 0 100%);">
    <div class='grid grid-cols-2 gap-12 items-center px-2 text-start md:text-start md:pl-36 my-6 md:my-10 w-[100%]' style=" shape-outside: polygon(310px 0px, 130px 405px, 558px 405px);
      ">
      <div style="z-index: 2; overflow: visible;">
        <div class="flex items-center pb-4">
          <i class="fa-solid fa-chart-simple text-7xl p-6 text-white"></i>
          <h2 class="text-5xl font-extrabold">County Revenue <br>Collection</h2>
        </div>
        <h3 class="text-4xl space-y-4 bg-clip-text">We Are Number 1 In Counties <br>Revenue Collection Systems In.... .</h3>
      </div>
      <img class="img mdl-28 overflow-visible z-30 h-full w-full" src="../media/images/computer.png" alt="image" />
    </div>
  </div>
</div>

1

There are 1 answers

1
Ashir Hashmi On BEST ANSWER

The easiest way to solve this is to use ::before or ::after pseudo element. Try:

.hero-section {
  position: relative;
  width:150px;
  height: 150px;
  background-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index:1;
}
.hero-section::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  z-index:-1;
  background-color: blue;
  clip-path: polygon(0 0, 100% 0, 41% 100%, 0% 100%);
}
<section class="hero-section">
  <h1>Hello World</h1>
</section>