0

i really need your help..

did anyone know how to make a shape like this using css?

enter image description here

i tried to make it, but now i stuck..

here's my code pen

Here's the css style and HTML

.a {
  width: 20%;
  height: 500px;
  background-color: red;
  display: inline-block;
  margin: 0;
}
.b {
  display: inline-block;
  position: absolute;
  width: 20%;
  height: 500px;
  background-color: black;
  margin: 0;
  border-radius: 50% 0 0 50%;
  left: 20%;
}
<div id="container">
  <div class="a">
    ...
  </div>
  <div class="b">
    ...
  </div>
</div>

7
  • 1
    what's the problem? you appear to have created the same shape in your picture... Commented Jan 19, 2016 at 14:35
  • Related to (and possibly a duplicate of) stackoverflow.com/questions/8503636/… Commented Jan 19, 2016 at 14:36
  • @liam_g: The html tag doesn't really make much of a difference to this question. Not sure why you had suggested that alone as an edit when there are multiple other things to be fixed in the post. Commented Jan 19, 2016 at 14:40
  • I already make it transparent, but it still doesnt trim the red shape. Commented Jan 19, 2016 at 14:47
  • ooww, someone already solve this question ! okaay, thanks guys.. Commented Jan 19, 2016 at 14:52

2 Answers 2

1

CSS Radial Gradient

One way to achieve this would be to use a radial gradient background. This will also make your background transparent in the area you require so it should be to your requirements.

body {
  background: lightblue;
}
div {
  background: radial-gradient(circle at 250% 25%, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0) 50%, red 50%, red 100%);
  /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
  background-size: 100% 200%;
  height: 400px;
  width: 200px;
}
<div>Text</div>

Sign up to request clarification or add additional context in comments.

Comments

1

An other way to achieve this would be to use css-Shadow and pseudo-elements

div {
    position: relative;
    overflow: hidden;
    margin: 20px auto;
    height: 400px;
    width: 200px;
}

div:before{
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    box-shadow: 0 0 0 200px red;
    height: 100%;
    width: 100%;
    border-radius:50%;
}
<div></div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.