3

I was tring to make a semi circle in css. (without border and out)

I have also tried this.But,unable

clip-path: circle(100% at 0%);

4 Answers4

4

I tried changing the clip-path to 50% and also you have to have a width and a height to the element.

.wrapper{
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.semi-circle{
  width: 100px;
  height: 100px;
  background-color: green;
  clip-path: circle(50% at 0%);
}
 <div class="wrapper">
  <div class="semi-circle">
  </div>
 </div>

The height and width are equal and this is also important. Hope it helped :)

claricetorres
  • 128
  • 1
  • 8
1

You can use canvas to make almost any shape you want. Try the .arc() prop of canvas. .arc( x, y, r, startAngle, endAngle) where : x: x co-ord of centre of circle y: y co-ord of centre of circle r: radius of circle startAngle: start angle in radians to draw the arc endAngle: end angle in radians to draw the arc

<!DOCTYPE HTML>
<html>
  <head>
    <style>
      body {
        margin: 0px;
        padding: 0px;
      }
    </style>
  </head>
  <body>
    <canvas id="myCanvas" width="578" height="200"></canvas>
    <script>
      var canvas = document.getElementById('myCanvas');
      var context = canvas.getContext('2d');

      context.beginPath();
      context.arc(100, 100, 50, 0*Math.PI,Math.PI, false);
      context.closePath();
      context.fillStyle = 'red';
      context.fill();
    </script>
  </body>
</html>     

Here's the jsfiddle link for the same: https://jsfiddle.net/khushboo097/skoqr28w/7/

Khushboo
  • 96
  • 5
0

I'm not sure this is what you want, but you could use something like this:

#circle {
  background-color: black;
  width: 100px;
  height: 100px;
  border-radius: 50%;
}

#container {
  width: 50px;
  overflow: hidden;
}
<div id="container">
  <div id="circle"></div>
</div>
cs1349459
  • 911
  • 9
  • 27
0
    <!DOCTYPE HTML>
    <html>
         <head>
              <style>
                     .semicircle:before {
                       content: "";
                       height: 100px;
                       width: 100px;
                       border-radius: 50%;
                       position: absolute;
                       background-color: #eee;
                     }

                     .semicircle {
                       position: relative;
                       height: 50px;
                       width: 100px;
                       overflow: hidden;
                     }
              </style>
       </head>
       <body>
            <div class="semicircle"></div>
       </body>
</html>

I hope it works.