CSS Shadows all four sides of div

前端 未结 11 1531
青春惊慌失措
青春惊慌失措 2021-02-08 11:18

I want to achieve this in CSS - not CSS3 as I want it to be supported by all browsers

ie a div containing content, with the shadows on every side. The top area will be

相关标签:
11条回答
  • 2021-02-08 11:38

    You have to create several images. One for the left side. One for the right. One for the bottom, etc. And then have several div's and set the background for each of them.

    0 讨论(0)
  • 2021-02-08 11:42

    Box Shadow works in all mordern [IE>8] browsers, This code uses no images and works in all browsers in IE versions below 9.

     box-shadow:2px 2px 10px 10px #C9C9C9;
     -webkit-box-shadow:2px 2px 10px 10px #C9C9C9;
     -moz-box-shadow:2px 2px 10px 10px #C9C9C9;
    
      /* For IE<9 */  
      filter:
      progid:DXImageTransform.Microsoft.Shadow(color=#C9C9C9,direction=0,strength=5),
      progid:DXImageTransform.Microsoft.Shadow(color=#C9C9C9,direction=45,strength=2),
      progid:DXImageTransform.Microsoft.Shadow(color=#C9C9C9,direction=90,strength=5),
      progid:DXImageTransform.Microsoft.Shadow(color=#C9C9C9,direction=135,strength=5),
      progid:DXImageTransform.Microsoft.Shadow(color=#C9C9C9,direction=180,strength=10),
      progid:DXImageTransform.Microsoft.Shadow(color=#C9C9C9,direction=225,strength=5),
      progid:DXImageTransform.Microsoft.Shadow(color=#C9C9C9,direction=270,strength=5),
      progid:DXImageTransform.Microsoft.Shadow(color=#C9C9C9,direction=315,strength=2);
    

    Box shadow supported from IE 9 onwards.

    0 讨论(0)
  • 2021-02-08 11:42

    CSS3pie is a tool that lets you use some css3 properties in IE.

    What you're trying to do is fairly widespread css3 in newer browsers, and emulated really well (and easily) in IE with the .htc file you can download from there.

    As for the markup, I see just 2 elements, with the top one floated right, for example. You'd have to play with z-index to hide excess shadows. In that site there's also a very similar effect, you should be able to adapt it for your needs.

    0 讨论(0)
  • 2021-02-08 11:46

    This should work in all browsers:

    
        .allSidesShadow {
            box-shadow: 2px 2px 19px #aaa;
            -o-box-shadow: 2px 2px 19px #aaa;
            -webkit-box-shadow: 2px 2px 19px #aaa;
            -moz-box-shadow: 2px 2px 19px #aaa;
    
            /* For IE 5.5 - 7 */
            /* for IE4 - IE7 */
            filter:
                progid:DXImageTransform.Microsoft.Shadow(Strength=9, Direction=1, Color=#C4C4C4),
                progid:DXImageTransform.Microsoft.Shadow(Strength=9, Direction=90, Color=#C4C4C4),
                progid:DXImageTransform.Microsoft.Shadow(Strength=9, Direction=180, Color=#C4C4C4),
                progid:DXImageTransform.Microsoft.Shadow(Strength=9, Direction=270, Color=#C4C4C4);
            -ms-filter: "
                progid:DXImageTransform.Microsoft.Shadow(Strength=9, Direction=1, Color=#C4C4C4),
                progid:DXImageTransform.Microsoft.Shadow(Strength=9, Direction=90, Color=#C4C4C4),
                progid:DXImageTransform.Microsoft.Shadow(Strength=9, Direction=180, Color=#C4C4C4),
                progid:DXImageTransform.Microsoft.Shadow(Strength=9, Direction=270, Color=#C4C4C4)
            ";
        }
    
    
    0 讨论(0)
  • 2021-02-08 11:48

    I cant see your picture now, but for all side shadows I use the below code:

    box-shadow: 0 0 5px 0 #000;
    

    Instead of the 5px use your size.

    0 讨论(0)
  • 2021-02-08 11:49

    You can do this with three divs, assuming they are all the same (fixed) width:

    <div class='top'>
    </div>
    <div class='middle'>
    <p>Hello World!</p>
    </div>
    <div class='bottom'>
    </div>
    
    .top{
      background:url('top.png');
      height:20px;
      width:800px;
    }
    .middle{
      background:url('middle.png') repeat-y;
      width:800px;
      }
    .bottom{
      background:url('bottom.png');
      height:20px;
      width:800px;
    }
    
    0 讨论(0)
提交回复
热议问题