Search code examples
cssscaletransform

CSS3 inner shadow disappear on scaling


i'm trying to scale a div with a inner shadow and an image inside. Here is the code:

 <!DOCTYPE html>
    <html>
       <head>
          <title> Home Page </title>  
          <style>

             div#b{
                box-shadow:0 0 10px 2px  #fff inset;
                border-radius:10px;
                width:230px;
                height:150px;
                transition: all 1s ease;
             }

             div#b:hover {
                position:relative;
                z-index:3;
                transform:scale(1.2,1.2) rotate(0.02deg);
             }

             div#b img{
                width:230px; 
                height:150px;
                border-radius:10px;
                position: relative;
                z-index:-2;
             }

          </style>
       </head>
       <body>

          <div id="b">
             <a href="#">
                <img src="img.jpg" alt="img" title="myimg">
             </a>
          </div>

       </body>
    </html>

The problem is that when hovering the mouse on the div, the image comes upon the div hiding the inner shadow.

I've already tried to z-index:3 the div:hover but no results. May you help me?

Thanks in advance


Solution

  • Add box-shadow: 0 0 10px 2px #fff inset; and display: inline-block; to the div#b a

    JSFiddle - DEMO

    div#b a {
        display: inline-block;
        box-shadow:0 0 10px 2px #fff inset;
    }
    div#b img {
        width:230px;
        height:150px;
        border-radius:10px;
        position: relative;
        z-index:-2;
        vertical-align: middle;
    }