Meet Bhalodiya
Meet Bhalodiya

Reputation: 916

Can we make this shape using CSS

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?

Upvotes: 1

Views: 114

Answers (5)

Temani Afif
Temani Afif

Reputation: 273969

One div, one gradient

div {
  width: 100px;
  height: 100px;
  border: solid gold;
  border-width: 20px 40px;
  background: radial-gradient(circle 50px, gold 98%, #0000) -50px -50px content-box green
}
<div></div>

Upvotes: 1

Mohib Arshi
Mohib Arshi

Reputation: 830

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 - https://jsfiddle.net/81wbLku2/

Upvotes: 1

Paulie_D
Paulie_D

Reputation: 115295

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>

Upvotes: 3

X3R0
X3R0

Reputation: 6327

FSFiddle

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;
}

Upvotes: -2

Zahra Nikkhah
Zahra Nikkhah

Reputation: 50

use can use border-radius style with 4 div : one div at left top location style is

border-radius: 0px 0px 100px 0px; 
border: 10px solid #800000;

another div at right top location style is

border-radius: 0px 0px 0px 100px; 
border: 10px solid #800000;

another div at right bottom location style is

border-radius: 100px 0px 0px 0px; 
border: 10px solid #800000;

another div at left bottom location style is

 border-radius: 0px 100px 0px 0px; 
border: 10px solid #800000;

Upvotes: -2

Related Questions