Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS3 skew all corners

I'm trying to skew my menu items like this:

enter image description here

I've found a few solution that will let me skew all 4 corners but they use a border-top solution whilst I need to use a background-image solution because of the gradient.

Does anybody know how to do this?

like image 970
LookingForAnswers Avatar asked Sep 14 '25 16:09

LookingForAnswers


2 Answers

It's not possible to move each corner around freely, but you can combine skew with rotate and transform-origin to create a lot of different effects. Here's a demo of something similar to the picture you shared.

If you need something more intricate, it'd likely be best to use SVG.

like image 52
Zach Saucier Avatar answered Sep 17 '25 19:09

Zach Saucier


You can build it with a separate gradient for each zone

div {
    width: 400px;
    height: 200px;
    background-image: linear-gradient(6deg, blue 19%, transparent 10%),
        linear-gradient(80deg, green 12%, transparent 10%),
        linear-gradient(175deg, red 18%, transparent 10%),
        linear-gradient(275deg, yellow 18%, transparent 10%),
        linear-gradient(6deg, lightblue 21%, transparent 10%),
        linear-gradient(80deg, lightgreen 13%, transparent 10%),
        linear-gradient(175deg, lightcoral 21%, transparent 10%),
        linear-gradient(275deg, lightyellow 19%, transparent 10%);
}

demo

like image 28
vals Avatar answered Sep 17 '25 20:09

vals