I’m trying to replicate the VueJS logo with a CSS-only approach, not by importing an SVG or anything.
I’ve use clippy to have some proper clip-path
, but still there is no way for me to find the proper rotation between the arms of the logo.
This is what I tried so far
.wrapper {
height: 100svh;
display: flex;
flex-direction: row;
align-items: center;
transform: rotate(-60deg)
}
.wrapper div {
width: 250px;
height: 45px;
}
.left {
transform: rotate(-60deg) translate(60%, 200%) scale(-1);
}
.green {
background-color: #42b883;
clip-path: polygon(33px 0, calc(100% - 33px) 0, 100% 100%, 0% 100%);
}
.blue {
background-color: #35495e;
clip-path: polygon(
66px 0,
calc(100% - 66px) 0,
calc(100% - 33px) 100%,
33px 100%
);
}
<div class="wrapper">
<main class="left">
<div class="blue"></div>
<div class="green"></div>
</main>
<main class="right">
<div class="blue"></div>
<div class="green"></div>
</main>
</div>
I’ve tried various translations, transforms etc, but none of them seem to be logical, while I thought that applying a 60-degree rotation would be enough.
Turns out it totally didn’t.
2
Answers
If you want to go with the
clip-path
technique, that works, but I might stick to only using clip-path, as opposed to trying to rotate and mirror your figure path after you’ve created it. clip-path is powerful enough to handle it all. Refer to this MDN page for information on how to useclip-path
withpolygon()
– it’s not overly difficult – it’s just a comma separated list of coordinate pairs where each value can simply be defined as a percentage.In the below example, I’m creating two divs, one for blue, and the other for green. I layer the two divs over each other and set their size to be the exact same.
If you instead want to go strong with the rotating/shifting stuff, here’s how you might go about doing that (without using
clip-path
).Step 1: Create a dark-blue div with a green bottom-border. Move and rotate it into position. The top will be cut off simply because it’s shooting out above the top of the page.
Step 2: Put our figure inside of a container. Give the container a fixed size, and configure it to crop anything that extrudes out of it (with
overflow: hidden
).In the below example, I’ll outline the box that does the cropping in red, so it’s easier to see what’s going on.
Step 3: Now we just need to mirror it to the other side. I’m going to accomplish this by copy-pasting the exact same HTML, but I’ll put the pasted HTML inside of a container div that contains CSS to flip it.
Ta-Dah!
You can get it using a single div, using just 2 gradients: