Home > Back-end >  Can we make this shape using CSS
Can we make this shape using CSS

Time:09-28

I was wondering how to make different shapes using CSS and I came across this one

enter image description here

Yes, I can make it using more than one element that's four circles and the background of the body, but is there any way so I can make it using a single div element?

we will have to make a square div with inside curves is that possible using CSS?

CodePudding user response:

One div, 4 radial gradients.

div {
  width: 80vh;
  height: 80vh;
  border: 1px solid red;
  margin: 1em auto;
  background-color: black;
  background-image: radial-gradient(circle at 100% 0%, orange, orange 36%, transparent 36%), radial-gradient(circle at 0% 0%, orange, orange 36%, transparent 36%), radial-gradient(circle at 100% 100%, orange, orange 36%, transparent 36%), radial-gradient(circle at 0% 100%, orange, orange 36%, transparent 36%)
}
<div></div>

CodePudding user response:

One possible way to do it:

  • Create a div
  • Create a before element to that div and use clip-path property.
  • On clip-path there is a path value and you can put a svg path to it.

Below is the implementation

<div class="container">
</div>
div.container {
  height:300px;
  width:300px;
  background: #F3AC3C;
  display:flex;
  justify-content:center;
  align-items: center;
}

div.container::before {
  content: '';
  display:block;
  height:100%;
  width:100%;
  background: #1A4341;
  clip-path: path('M150,70 q1,75 -76,75 q77,-1 76,76 q-1,-76 74,-77 q-74,0 -74,-74 q0.5,62.5 1,75 q-1,25 -2,0 q1,24.5 2,-1')
}

jsfiddle - enter image description here

<div class="g">
  <div class="y" style="border-bottom-right-radius: 100px;"></div>
  <div class="y" style="border-bottom-left-radius: 100px;"></div>
  <div class="y" style="border-top-right-radius: 100px;"></div>
  <div class="y" style="border-top-left-radius: 100px;"></div>
</div>
* {
  margin:0px;
  padding: 0px;
}

.g {
  background: #1A4341;
  width: 400px;
  height: 200px;
  display: grid;
  grid-template-columns: 50% 50%;
  grid-template-rows: 50% 50%;
}

.y {
  background: #F3AC3C;
  width: 100%;
  height: 100%;
  display: block;
}
  • Related