CSS Shadows all four sides of div

2020-06-03 03:50发布

I want to achieve this in CSS - not CSS3 as I want it to be supported by all browsers bg with shadows on all sides

ie a div containing content, with the shadows on every side. The top area will be used for navigation. I have searched for tutorials but so far to no avail. Help!

12条回答
一夜七次
2楼-- · 2020-06-03 04:02

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;
}
查看更多
可以哭但决不认输i
3楼-- · 2020-06-03 04:05

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.

查看更多
再贱就再见
4楼-- · 2020-06-03 04:07

As Ventus said is not possible to use css shadows with ie (only ie9). But you can use shadowOn. It's a great jquery plugin and very easy in use. With it you will have cross browser compatibility.

查看更多
够拽才男人
5楼-- · 2020-06-03 04:11

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.

查看更多
爷、活的狠高调
6楼-- · 2020-06-03 04:11

You can place the following code in the div in order to drop shadows on all four sides.

-webkit-box-shadow: 0 0 10px rgba(0,0,0,.1);
box-shadow: 0 0 10px rgba(0,0,0,.1);    
查看更多
Lonely孤独者°
7楼-- · 2020-06-03 04:16
box-shadow: inset 0 0 3px 0 #000;

Means 0 pixel left, 0 pixel right, 3px blur, 0 pixel diffuse, use a color slightly darker than the BGs.

查看更多
登录 后发表回答