Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Border shadow on one edge of a CSS triangle

I have this CSS triangle:

http://codepen.io/orweinberger/pen/myEoVa

CODE:

*,
*:before,
*:after {
  box-sizing: border-box;
}
.triangle {
  position:absolute;
  bottom:0;
  right:0;
  display: inline-block;
  vertical-align: middle;
}
.triangle-0 {
  width: 200px;
  height: 200px;
  border-bottom: solid 100px rgb(85,85,85);
  border-right: solid 100px rgb(85,85,85);
  border-left: solid 100px transparent;
  border-top: solid 100px transparent;
}

.text {
  color:#fff;
  position:absolute;
  bottom:0;
  right:0;
}

Is it possible to add a shadow to one of the edges, similar to this?

http://codepen.io/orweinberger/pen/ByzbKX

like image 701
Or Weinberger Avatar asked Dec 21 '14 12:12

Or Weinberger


People also ask

How do you put a shadow on one side in CSS?

box-shadow: h-offset v-offset blur spread color; box-shadows values: h-offset: It is required and used to set the position of the shadow horizontally. The positive value is used to set the shadow on right side of the box and a negative value is used to set the shadow on the left side of the box.

How do I cast a shadow in CSS?

A light source positioned above an element will cast a shadow below the element. Placing a light source to the left of an element will cast a shadow to the right. Placing multiple light sources to the top, bottom, left and right of an element actually casts no shadow at all!


1 Answers

You can use another approach for the triangle to be able to apply a box-shadow to it :

body {
  overflow: hidden;
}
div {
  position: absolute;
  bottom: 0;
  right: 0;
  height: 150px;
  width: 213px;
  background: lightgrey;
  -webkit-transform-origin:100% 0;
  -ms-transform-origin:100% 0;
  transform-origin: 100% 0;
  -webkit-transform: rotate(-45deg);
  -ms-transform: rotate(-45deg);
  transform: rotate(-45deg);
  box-shadow: 0px -3px 5px 0px #656565;
}
<div></div>

More info here on triangles with transform rotate

like image 76
web-tiki Avatar answered Oct 02 '22 13:10

web-tiki