dev.meghraj
dev.meghraj

Reputation: 9120

How achieve rounded shadow behide a rounded element using css3

i want to make a element look like in this image

Round shadow on element

i have tried a a lot to do this kind of shadow in css, and finally think why not ask to community about it, whether its possible or not.

i know in box-shadow means shadow on box. is there something like round-shodow

i want it in css3 without any images. is it possible? if yes then how is it possible? if no than ok.

i know box-shadow and border-radius very so please don't tell me about that things, check again its different kind of shadow

Upvotes: 3

Views: 206

Answers (3)

Travis
Travis

Reputation: 2245

If want an easy way to do this with JS i have had really good luck with this

https://github.com/heyimjuani/iluminate

Upvotes: 1

user1618143
user1618143

Reputation: 1748

Okay, here's some css that gives you about the effect you're asking for:

.circle { background: red; border-radius: 50%; width: 50px; height:50px;position:relative;}
.circle:before {
    background: -moz-linear-gradient(top, rgba(136,136,136,0.4) 0%, rgba(136,136,136,0) 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(136,136,136,0.4)), color-stop(100%,rgba(136,136,136,0))); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, rgba(136,136,136,0.4) 0%,rgba(136,136,136,0) 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, rgba(136,136,136,0.4) 0%,rgba(136,136,136,0) 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top, rgba(136,136,136,0.4) 0%,rgba(136,136,136,0) 100%); /* IE10+ */
    background: linear-gradient(to bottom, rgba(136,136,136,0.4) 0%,rgba(136,136,136,0) 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#66888888', endColorstr='#00888888',GradientType=0 ); /* IE6-9 */
    width:100%;
    height:75%;
    display: block;
    content: " ";
    position: relative;
    top: 22px;
    right: 15px;
    z-index: -1;
    -webkit-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform:rotate(45deg);
}

Fiddle: http://jsfiddle.net/RKwdj/

Upvotes: 0

Chad
Chad

Reputation: 5418

Here's a starting point at least. You can use the before (and after) pseudo elements. http://jsfiddle.net/FHLJM/

div {
    background-color: #f00;
    border-radius: 50%;
    height: 250px;
    width: 250px;
    margin: 30px auto;
    position: relative;
    z-index: 1;
}
div:before {
    content: '';
    height: 150px;
    width: 250px;
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#000), to(#fff));;
    position: absolute;
    top: 100px;
    right: 50px;
    -webkit-transform: rotate(45deg);
    z-index: -1;
}
div:after {
    content: '';
    height: 100%;
    width: 100%;
    border-radius: 50%;
    background: #f00;
    position: absolute;
    z-index: 1;
}

Again, it's not a perfected method by any means, but it is able to accomplish what you're looking for to some degree.

Upvotes: 5

Related Questions