How can I maintain proper boundaries on CSS triangles when hovering with cursor?

前端 未结 3 1246
旧巷少年郎
旧巷少年郎 2020-12-10 04:07

Is it possible to fix the hovering on http://jsfiddle.net/2AXhR/ so that the correct triangle is activated on hover instead of its sometimes adjacent one? Sometimes the wron

3条回答
  •  难免孤独
    2020-12-10 04:48

    Here is a completely different approach. It avoids the boundary issues completely.

    It's worth noting that this approach is relatively limited when it comes to achieving the hover effect you had in place. I'm currently looking at alternatives.

    EXAMPLE HERE - Works in FF/Chrome it fails in IE11.

    HTML

    CSS

    .t {
        width:500px;
        height:500px;
        position:relative;
    }
    .t > .clip {
        overflow: hidden;
        position: absolute;
        width: 50%;
        height: 50%;
        -webkit-transform-origin: 100% 100%;
    }
    .t > .clip:first-child {
        -webkit-transform: rotate(60deg) skewY(30deg);
    }
    .t > .clip:nth-child(2) {
        -webkit-transform: rotate(120deg) skewY(30deg);
    }
    .t > .clip:nth-child(3) {
        -webkit-transform: rotate(180deg) skewY(30deg);
    }
    .t > .clip:nth-child(4) {
        -webkit-transform: rotate(240deg) skewY(30deg);
    }
    .t > .clip:nth-child(5) {
        -webkit-transform: rotate(300deg) skewY(30deg);
    }
    .t > .clip:nth-child(6) {
        -webkit-transform: rotate(360deg) skewY(30deg);
    }
    .triangle {
        width: 200%;
        height: 200%;
        -webkit-transform: skewY(-42deg) skewX(-20deg) rotate(-15.5deg);
        background:#0079c5;
    }
    .triangle:hover {
        background:#009cff;
    }
    

提交回复
热议问题