DEV Community

Cover image for CSS Battle: #14 - Web Maker Logo
Jatin Sharma
Jatin Sharma

Posted on • Originally published at j471n.in

CSS Battle: #14 - Web Maker Logo

In this article, I will solve a Web Maker Logo CSS Challenge on CSS Battle. Let's look at the problem first.

Problem

We need to create the following container by using CSS Properties only:
Web Maker Logo

Solution

So now look at the Solution and how we are going to achieve this.

HTML

<div wl><p l></div>
<div wr><p r>
Enter fullscreen mode Exit fullscreen mode
  • <div wl> : wrapper for left polygon
  • <div wr> : wrapper for right polygon
  • <p l> : Left polygon
  • <p r> : Right polygon

CSS

Now let's style the containers.

body {
  margin: 0;
  background: #f2f2b6;
  display: grid;
  place-items: center;
}
p {
  position: fixed;
  width: 150;
  height: 130;
  clip-path: polygon(100% 0, 0 0, 50% 100%);
}

[wl] {
  filter: drop-shadow(20px 0 #fd4602);
}

[l] {
  background: #ff6d00;
  left: -140;
  top: -6;
}

[wr] {
  filter: drop-shadow(20px 0 #ff6d00);
}

[r] {
  background: #fd4602;
  transform: scaleY(-1);
  bottom: -6;
  left: -30;
}
Enter fullscreen mode Exit fullscreen mode

I am using a wrapper because we cannot add box-shadow to the clip-path. However, If you wrap the clip-path in some div and then apply the drop-shadow then it works. That's what I did here.

Note: In CSS Battle you can use 100 instead of 100px. You don't need to define px in CSS. However, if you are using rem or %, you need to pass them separately. That's why in the above CSS code there are no units mostly. For more info visit here

Minify the code or CSS by using any CSS Minifier. It helps you to reduce the characters in the code which will increase the score.

Minified Version:

<div wl><p l></div><div wr><p r><style>body{margin:0;background:#F2F2B6;display:grid;place-items:center}p{position:fixed;width:150;height:130;clip-path:polygon(100% 0,0 0,50% 100%)}[wl]{filter:drop-shadow(20px 0 #FD4602)}[l]{left:-140;top:-6;background:#FF6D00}[wr]{filter:drop-shadow(20px 0 #FF6D00)}[r]{background:#FD4602;bottom:-6;left:-30;transform:scaleY(-1)}
Enter fullscreen mode Exit fullscreen mode

Wrapping up

There are many ways to solve this. You can share your approach in the comments. If you like this then don't forget to โค๏ธ it. And I'll see you in the next article. See you soon.

Top comments (3)

Collapse
 
mshahanwaz profile image
Mohammad Shahanwaz • Edited
<div></div>
<div></div>
<style>
  body {
    background: #F2F2B6;
    display: flex;
    justify-content: center;
    align-items: center;
    height: calc(100vh - 16px);
  }
  div {
    --a: 150px;
    filter: drop-shadow(20px 0 currentcolor);
    width: 0;
    height: 0;
    color: #FD4602;
    border-top: calc(0.866 * var(--a)) solid #FF6D00;
    border-left: calc(var(--a) / 2) solid transparent;
    border-right: calc(var(--a) / 2) solid transparent;
    border-bottom: 0;
  }
  div ~ div {
    color: #FF6D00;
    border-bottom: calc(0.866 * var(--a)) solid #FD4602;
    border-top: 0;
    margin: 0 20px 0 -40px;
  }
</style>
Enter fullscreen mode Exit fullscreen mode
Collapse
 
j471n profile image
Jatin Sharma

using border is also impressive. Keep it up.

Collapse
 
gass profile image
Gass

Your explanation of the use of box-shadow and clip-path was very useful. It wasn't an easy challenge for me. Here is my solution ;)

<section class='box'>
  <div class='shadow-effect1'>
    <div class='triangle inverted left'></div>
  </div>
  <div class='shadow-effect2'>
    <div class='triangle right'></div>
  </div>
</section>
Enter fullscreen mode Exit fullscreen mode
body{
    background:#F2F2B6;
  }
  .box{
    margin:85px 0 100px 51px;
    width:283px;
    height:130px;
  }
  .triangle {
    position:absolute;
    width: 151px;
    height: 130px;
    clip-path: polygon(0% 100%, 100% 100%, 50% 0%);
  }
  .shadow-effect1{
    filter: drop-shadow(20px 0px #FD4602);
  }
  .shadow-effect2{
    filter: drop-shadow(20px 0px #FF6D00);
  }
  .inverted{
    transform:rotate(180deg);
  }
  .right{
    background:#FD4602;
    right:22px;
  }
  .left{
    background:#FF6D00;
  }
Enter fullscreen mode Exit fullscreen mode