DEV Community

Cover image for CSS Battle: #15 - Overlap
Jatin Sharma
Jatin Sharma

Posted on • Originally published at j471n.in

CSS Battle: #15 - Overlap

In this article, I will solve a Overlap 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:
Overlap

Solution

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

HTML

<p> 
<a> 
Enter fullscreen mode Exit fullscreen mode
  • <p> : Circles
  • <a> : overlap of both circles

CSS

Now let's style the containers.

* {
  background: #09042a;
}

body {
  margin: 75;
}

p, a {
  border-radius: 1in;
  width: 150;
  height: 150;
}
p {
  background: #7b3f61;
  position: relative;
  overflow: hidden;
  box-shadow: 100px 0 #e78481;
}

a {
  position: absolute;
  left: 100;
}
Enter fullscreen mode Exit fullscreen mode

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:

<p><a><style>*{background:#09042A}body{margin:75}p,a{border-radius:1in;width:150;height:150}p{background:#7B3F61;position:relative;overflow:hidden;box-shadow:100px 0 #E78481}a{position:absolute;left:100}
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 (2)

Collapse
 
gass profile image
Gass

Very nice solution, I didn't think about using overflow and so I was stuck with this challenge. Thanks

Collapse
 
j471n profile image
Jatin Sharma

It's my pleasure. Keep hacking โœจ