Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How this css only pointed corner was generated

Tags:

css

Can somebody help me understand how this pointed corner was actually generated in css only(Rather, please help me understand how this is actually working): The code is-

<p class="test-div">
  <span class="price">
   Rs.5.00
  </span>

</p>

CSS

.test-div {
   margin: 24px 100px 0;
}
.test-div .price:before {
   border-right: 40px solid #25A0DA;
   border-top: 24px solid transparent;
   content: "";
   display: block;
   position: absolute;
   right: 100%;
   top: 0;
}

.test-div .price {
   background-color: #25A0DA;
   color: #FFFFFF;
   display: inline-block;
   margin-left: -2em;
   padding: 0 0.5em;
   position: relative;
   line-height:24px;
   font-size:14px;
}

For a live example please check- http://dabblet.com/gist/1662113

like image 935
saji89 Avatar asked Mar 15 '26 11:03

saji89


1 Answers

The "triangle border trick" is being used.

Read this question for all the info you could ever want: How do CSS triangles work?

like image 82
thirtydot Avatar answered Mar 21 '26 09:03

thirtydot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!