How to create a page that's split diagonally and the two halves are clickable links

前端 未结 3 1511
予麋鹿
予麋鹿 2021-02-10 17:25

I need to create a landing page that\'s split diagonally. Something like this

\"enter

3条回答
  •  梦如初夏
    2021-02-10 17:48

    I know this is an old topic, but I was looking for a solution myself and ended up figuring out that SVG is the real, cross-browser answer. You can have links directly in the SVG.

    Also on CodePen

    html, body {
      margin: 0;
    }
    div {
      position: absolute;
      width: 100%;
      height: 100%;
    }
    svg {
      display: block;
      width: 100%;
      height: 100%;
    }
    svg > a:first-child > path {
      cursor: pointer;
      fill: #ccc;
    }
    svg > a:last-child > path {
      cursor: pointer;
      fill: #999;
    }

    This solution works in modern browsers, Edge, and IE11. I didn't test any older browsers.

    For some reason Chrome will not show the "pointer" cursor unless it is specifically added to the path CSS.

提交回复
热议问题