2

I have a div with rounded corners but I would like to invert these rounded corners to create a bowl effect.

Here is what I currently have:

html{
  background:red;
}

#test {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 150px;
  border-top-left-radius: 50%;
  border-top-right-radius: 50%;
  background: blue;
}
<div id="test"></div>

So instead, I would like it to look like:

Border Example

Is this even possible with CSS?

Update

If not already clear, the 'red' is meant to illustrate the rest of the body of the page and will need to be transparent

Community
  • 1
  • 1
Ben Carey
  • 16,540
  • 19
  • 87
  • 169

2 Answers2

1

Change top to bottom.

border-bottom-left-radius: 50%; border-bottom-right-radius: 50%;

Edit:

See Fiddle then.

Krii
  • 907
  • 9
  • 23
1

Create a pseudo element and rotate it by 180deg.

html {
  background: red;
}

#test {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 150px;
  background: blue;
}

#test::before {
  content: "";
  border-top-left-radius: 50%;
  border-top-right-radius: 50%;
  background: red;
  position: absolute;
  top: 0px;
  height: 100px;
  width: 100%;
  transform: rotate(180deg);
}

Working Fiddle

Mr_Green
  • 40,727
  • 45
  • 159
  • 271
  • This is exactly the 'sort' of thing I was looking for, some clever way of manipulating the pseudo classes. However, there is on thing that makes this a few steps harder and that is the red is actually meant to be representing transparency. So actually, what I would like to do, is punch a bowl shape in the blue div. Is this even possible? – Ben Carey Feb 05 '16 at 18:30
  • @BenCarey AFAIK, there are all stupid tricks like I mentioned. I suggest you to go with SVGs instead. They are plain and straightforward. – Mr_Green Feb 05 '16 at 18:37
  • SVG is a great option. otherwise, making use of two elements, or a pseudo element is probably the best option. The spec does not really support what you are trying to do, so some hacky css backflips are going to be required. – Bosworth99 Feb 05 '16 at 22:36