shreyas35
shreyas35

Reputation: 175

how to create shape with half square and curved shape uisng css and html

i am trying to draw a shape exactly given in the image below

enter image description here

here is my html and css code which gives shape somewhat similar to this but in single color i am not getting how can i do it in multicolor. Can anybody explain me how i can do it. Thanks in advance.

.right-angle-triangle-semicircle {
  width: 100px;
  height: 100px;
  background: #FFA6DF;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 50%;
  border-bottom-left-radius: 0;
}
<div class="right-angle-triangle-semicircle"></div>

Upvotes: 1

Views: 200

Answers (3)

jbutler483
jbutler483

Reputation: 24549

Using just a single element, you can use a few small CSS tricks to achieve this.

No magic numbers, and will work with different resizing the element too.

Further to this, you can skip all the border-radius declarations into a single line.

border-radius: 0 0 50% 0;

.right-angle-triangle-semicircle {
  width: 100px;
  height: 100px;
  background: lightgray;
  border-radius: 0 0 50% 0;
  overflow: hidden;
  position: relative;
}

.right-angle-triangle-semicircle:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: #FFA6DF;
  width: 200%;
  transform: rotate(-45deg);
  transform-origin: bottom left;
}
<div class="right-angle-triangle-semicircle"></div>

Upvotes: 1

Helping Hands
Helping Hands

Reputation: 150

also you can use after or before

.right-angle-triangle-semicircle {
          width: 100px;
          height: 100px;
          background: #FFA6DF;
          border-top-left-radius: 0;
          border-top-right-radius: 0;
          border-bottom-right-radius: 50%;
          border-bottom-left-radius: 0;
          position: relative;    
        }
        .right-angle-triangle-semicircle:after {
            content: '';
            position: absolute;
            width: 0px;
            height: 0px;
            border-top: 70px solid transparent;
            border-bottom: 70px solid transparent;
            border-left: 70px solid #ccc;
            transform: rotate(225deg);
            top: -45px;
            left: -10px;
        }
<div class="right-angle-triangle-semicircle"></div>

Upvotes: 1

law_81
law_81

Reputation: 2420

Just use background:linear-gradient

Here you can check the documentation about linear-gradient

.right-angle-triangle-semicircle {
  width: 100px;
  height: 100px;
  background: #FFA6DF;
 background: linear-gradient(-45deg, #f0f0f0 0%, #f0f0f0 50%, #FFA6DF 50%, #FFA6DF 100%);
  
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 50%;
  border-bottom-left-radius: 0;
}
<div class="right-angle-triangle-semicircle"></div>

Upvotes: 3

Related Questions