Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blur borders on image via css

Tags:

html

css

I'm trying to do something like this:

example

I think it could be done using background image and another image (mask) above it with a transparent center. But is it possible to do the same with pure css?

like image 997
sealla Avatar asked Sep 04 '13 12:09

sealla


2 Answers

Whilst you can't apply a box-shadow directly to an image you could apply it with a :before or :after

    .shadow
    {
        display:block;
        position:relative;
    }
    
    img {
        width: 100%;
        height: 100%;
    }
    
    .shadow:before
    {
        display:block;
        content:'';
        position:absolute;
        width:100%;
        height:100%;
        -moz-box-shadow:inset 0px 0px 3px 1px rgba(0,0,0,1);
        -webkit-box-shadow:inset 0px 0px 3px 1px rgba(0,0,0,1);
        box-shadow:inset 0px 0px 3px 1px rgba(0,0,0,1);
    }
        <div class="shadow">
                <img src="http://lorempixel.com/400/200/" />
        </div>
like image 73
Jamie Hutber Avatar answered Oct 20 '22 19:10

Jamie Hutber


Yess it's possible like this:

.img {
border:1px solid black;
}
.img:hover {
border: none;
box-shadow: 0 0 10px black inset;
}
like image 20
Vladimir Avatar answered Oct 20 '22 18:10

Vladimir