Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Radial box-shadow on element

Is there a way to create a box-shadow that radiates in a circle from a rectangular div element? So like a regular shadow, except rounded.

like image 830
Alfred Xing Avatar asked Dec 16 '12 22:12

Alfred Xing


1 Answers

Strictly speaking - no. The box-shadow is tied to the shape of the object it's assigned to.

That said - assuming your code allows for nested div elements - you can effectively do this by styling a wrapping div as a circle with a drop-shadow, and the inner content div with the rectangular element.

.wrapper {
  /* Equal width and height create a perfect square */
  width: 300px;
  height: 300px;
  /* Adding a border-radius of 1/2 width or height (same value) */
  /* turns that square into a circle */
  border-radius: 150px;
  /* Apply your box-shadow styles, which inherit the round .wrapper shape */
  box-shadow: 0px 0px 200px #444444;
}

.content {
  /* Apply .content styles as needed; */
  /* will display on top of the round shadow */
  background-color: yellow;
}
<div class="wrapper">
  <div class="content">Content Here</div>
</div>
like image 191
Lauren G Avatar answered Oct 06 '22 16:10

Lauren G