Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can this image be a css box-shadow gradient?

Tags:

css

gradient

can I make this using box-shadow? right now it's an image but I'm wounding if this can be done with css box-shadow.

the shadow I want

like image 259
Lir An Avatar asked Jun 17 '13 12:06

Lir An


2 Answers

Working fiddle: http://jsfiddle.net/sinhayash/7dPnQ/1/

.class {
    height: 100px;
    width: 100px;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    -ms-border-radius: 5px;
    -o-border-radius: 5px;        
border-top: 3px solid rgb(16, 130, 253);
    border-bottom: 3px solid rgb(179, 216, 255);
    background-image: -webkit-gradient(linear, 0 0, 0 100%, from(rgb(16, 130, 253)), to(rgb(179, 216, 255)));
    background-image: -webkit-linear-gradient(#000, rgb(179, 216, 255));
    background-image:
        -moz-linear-gradient(rgb(16, 130, 253), rgb(179, 216, 255)),
        -moz-linear-gradient(rgb(16, 130, 253), rgb(179, 216, 255));
    background-image:
        -o-linear-gradient(rgb(16, 130, 253), rgb(179, 216, 255)),
        -o-linear-gradient(rgb(16, 130, 253), rgb(179, 216, 255));
    background-image: 
        linear-gradient(rgb(16, 130, 253), rgb(179, 216, 255)),
        linear-gradient(rgb(16, 130, 253),rgb(179, 216, 255));
    -moz-background-size: 3px 100%;
    background-size: 3px 100%;
    background-position: 0 0, 100% 0;
    background-repeat: no-repeat;
}

Working on firefox and chrome.

like image 103
sinhayash Avatar answered Sep 30 '22 05:09

sinhayash


I don't believe this can be done with box-shadow but it can be done with a combination of borders and background gradients.

DEMO

div { 
    width: 400px;
    padding: 20px 25px;
    border-top: 5px solid #4672bb;
    border-bottom: 5px solid #b8c9e5;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    -ms-border-radius: 5px;
    -o-border-radius: 5px;
    border-radius: 5px;
    margin: 40px auto;
    background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI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Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
    background-image: -webkit-linear-gradient(#4672bb, #b8c9e5);
    background-image:
        -moz-linear-gradient(#4672bb, #b8c9e5),
        -moz-linear-gradient(#4672bb, #b8c9e5)
    ;
    background-image:
        -o-linear-gradient(#4672bb, #b8c9e5),
        -o-linear-gradient(#4672bb, #b8c9e5)
    ;
    background-image: 
        linear-gradient(#4672bb, #b8c9e5),
        linear-gradient(#4672bb, #b8c9e5)
    ;
    -moz-background-size:5px 100%;
    background-size:5px 100%;
    background-position:0 0, 100% 0;
    background-repeat:no-repeat;
}

SVG's generated with the fantastic ColorZilla Gradient Generator

like image 33
Turnip Avatar answered Sep 30 '22 05:09

Turnip