Is it possible to do this with CSS?

div with circle, encompassing the drop shadow

Is there a good way to do this using HTML / CSS? Basically, a div that has a circle "kick" around the edge. This part is easy to use with pseudo classes, but my problem is that the shadow casts it as part of the form.

When I apply a shadow to a circle shadow separately, it does not work reliably. I know there is a way to do this ... but I'm not sure what browser support is.

What do you guys recommend the best way to handle this? Thank!

+5
source share
5 answers

You can get closer to this with a bunch of CSS. See this JSFiddle for a live example. However, there are disadvantages:

  • Poor support in IE below 9
  • , .
  • position: relative ( absolute)

CSS:

div {
    margin: 100px;
    width: 100px;
    height: 100px;
    box-shadow: 0 0 10px black;
    border-radius: 10px;
    position: relative;
}

div:before {
    display: block;
    content: "";
    width: 40px;
    height: 40px;
    position: absolute;
    left: -20px;
    top: 30px;
    border-radius: 20px;
    box-shadow: 0 0 10px black;
    clip: rect(-10px, 20px, 50px, -10px);
}
+5

, , , mozilla, safari chrome. css3, .

+2

CSS . . CSS3 , ..

, , "" , . . , .

+2

, , , -, .

, , , z-. , , . CSS3, , .

jsFiddle.

, , , .

#circ {
    border-radius: 40px;
    width:40px;
    height:40px;
    box-shadow: 0px 0px 10px #999;
    position: absolute;
    left: 37px;
    top: 77px;
    background: #fcfcfc;
    position:absolute;
    left: 40px;
    top:75px;
    /* Old browsers */
    background: -moz-linear-gradient(top, #fcfcfc 0%, #cccccc 100%);
    /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #fcfcfc), color-stop(100%, #cccccc));
    /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #fcfcfc 0%, #cccccc 100%);
    /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #fcfcfc 0%, #cccccc 100%);
    /* Opera 11.10+ */
    background: -ms-linear-gradient(top, #fcfcfc 0%, #cccccc 100%);
    /* IE10+ */
    background: linear-gradient(to bottom, #fcfcfc 0%, #cccccc 100%);
    /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fcfcfc', endColorstr='#cccccc', GradientType=0);
    /* IE6-9 */
    z-index: -1;
}
#rect {
    width:200px;
    height:80px;
    background: #fcfcfc;
    position:relative;
    left: 50px;
    top:50px;
    box-shadow: 0px 0px 10px #999;
    /* Old browsers */
    background: -moz-linear-gradient(top, #fcfcfc 0%, #cccccc 100%);
    /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #fcfcfc), color-stop(100%, #cccccc));
    /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #fcfcfc 0%, #cccccc 100%);
    /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #fcfcfc 0%, #cccccc 100%);
    /* Opera 11.10+ */
    background: -ms-linear-gradient(top, #fcfcfc 0%, #cccccc 100%);
    /* IE10+ */
    background: linear-gradient(to bottom, #fcfcfc 0%, #cccccc 100%);
    /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fcfcfc', endColorstr='#cccccc', GradientType=0);
    /* IE6-9 */
}

#circ2 {
    border-radius: 40px;
    width:40px;
    height:40px;
    position: absolute;
    left: 37px;
    top: 77px;
    background: #fcfcfc;
    position:absolute;
    left: 40px;
    top:75px;
        /* Old browsers */
    background: -moz-linear-gradient(top, #fcfcfc 0%, #cccccc 100%);
    /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #fcfcfc), color-stop(100%, #cccccc));
    /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #fcfcfc 0%, #cccccc 100%);
    /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #fcfcfc 0%, #cccccc 100%);
    /* Opera 11.10+ */
    background: -ms-linear-gradient(top, #fcfcfc 0%, #cccccc 100%);
    /* IE10+ */
    background: linear-gradient(to bottom, #fcfcfc 0%, #cccccc 100%);
    /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fcfcfc', endColorstr='#cccccc', GradientType=0);
    /* IE6-9 */
}
+1

border-radius css3, - .

:

HTML

<div id="wrap">
<div class="round">
    Border
</div>
</div>

CSS

html,body{
    background-color: #ccc;
    padding: 0;
    margin: 0;
}

#wrap{

    background-color: #fff;
    padding: 20px;
    width: 44%;
    margin: 20px;
    position: absolute;
    z-index: 1;
}

.round{
    width: 200px;
    padding: 20px;
    background-color: #fff;
    border-radius: 50px;
}

jsfiddle:

http://jsfiddle.net/RpE4G/

0

All Articles