Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Curve inside image with css

Tags:

html

css

Is it possible and how can i make a curve inside a image top and bottom, see image. How can i achieve this with css?

enter image description here

like image 661
Bas Avatar asked Apr 26 '17 02:04

Bas


1 Answers

Set your image as a background-image on a div and use this technique. I've used a solid red colour in my example.

Here i used pseudo elements to create the curves on the top and bottom. Notice the top and bottom offset is half of that of the height of each pseudo element and the border radius is set to 50%.

div {
  width:500px;
  height:200px;
  background:red;
  position:relative;
  overflow:hidden;
}
div:after, 
div:before {
  content:'';
  background:white;
  position:absolute;
  top:-10px;
  left:0;
  width:100%;
  height:20px;
  border-radius:0 0 50% 50%;
}
div:after {
  top:auto;
  bottom:-10px;
  border-radius:50% 50% 0 0 ;
}
<div></div>
like image 188
partypete25 Avatar answered Oct 01 '22 18:10

partypete25