Search code examples
htmlcsscss-shapes

CSS perspective shape URL doesn't work


I want to use a trapezoid shape made with CSS to house a link. But it doesn't seem to work. I'm not sure if it's because it's unsupported or because the code is bad. Seems like it should work! Anyone know why?

To clarify, I know the trapezoid works, but the link inside the trapezoid is dead.

My Code:

.box {
  width: 180px;
  height: 70px;
  position: relative;
  padding: 0px;
  left: 10%;
  text-transform: uppercase;
  text-align: center;
  padding-top: 34px;
  padding-bottom: 10px;
}
.box:before {
  content: "";
  position: absolute;
  border-radius: 1px;
  box-shadow: 0 1px 0 3px #27628e;
  top: -5%;
  bottom: -11%;
  left: -1%;
  right: -5%;
  z-index: ;
  -webkit-transform: perspective(50em) rotateX(-50deg);
  transform: perspective(50em) rotateX(-50deg);
}
<div class="box"><a href="http://google.com">google.com</a>
</div>


Solution

  • .box a{
    position:relative;
    }
    

    And it will work to click on the url.

    .box {
      width: 180px;
      height: 70px;
      position: relative;
      padding: 0px;
      left: 10%;
      text-transform: uppercase;
      text-align: center;
      padding-top: 34px;
      padding-bottom: 10px;
    }
    .box:before {
      content: "";
      position: absolute;
      border-radius: 1px;
      box-shadow: 0 1px 0 3px #27628e;
      top: -5%;
      bottom: -11%;
      left: -1%;
      right: -5%;
      z-index: ;
      -webkit-transform: perspective(50em) rotateX(-50deg);
      transform: perspective(50em) rotateX(-50deg);
    }
    .box a{
    z-index:999;
      position:relative;
    }
    <div class="box"><a href="http://google.com">google.com</a>
    </div>