Last Updated: August 30, 2016
·
6.244K
· chail93

Inset Box-Shadow At Images

Hey guys,
I've a little workaround for you. I had the problem to get an inset box-shadow at images. Because of this I try something in CSS and this works!

Markup

<div class="thumb">
    <a href="#">
        <img src="img.jpg" alt="avatar" title="bla">
    </a>
</div>

CSS

.thumb {
    a {
        position: relative;
        line-height: 0;
        display: inline-block;

        &:before {
              content: '';
              position: absolute;
              top: 0;
              bottom: 0;
              left: 0;
              right: 0;
              -webkit-box-shadow: (inset 0 1px 5px rgba(0,0,0,.55);
              -moz-box-shadow: (inset 0 1px 5px rgba(0,0,0,.55);
              box-shadow: (inset 0 1px 5px rgba(0,0,0,.55);
        }
        &:hover {
              opacity: .7;
        }
    }
}

5 Responses
Add your response

Great workaround, I've been looking for one!

I haven't seen CSS written in that style besides media queries. Where is this documented or further explained?

over 1 year ago ·

He's either using LESS or some other CSS framework.

over 1 year ago ·

this is SCSS.
and thanks for this, I am throwing it into my mixins right now..

over 1 year ago ·

And, by the way, you missed the closing parentheses on your box-shadow declarations

over 1 year ago ·

Thanks a Ton Tim.
Looking for this and finally found it here.
Thanks again for the solution. :)

over 1 year ago ·