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条回答
Root(大扎)
2楼-- · 2020-06-03 03:53

Alternatively, you can make one big image, and use that as the background for the entire content area; then hard-code the positions and sizes of the contained elements.

查看更多
兄弟一词,经得起流年.
3楼-- · 2020-06-03 03:57

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.

查看更多
倾城 Initia
4楼-- · 2020-06-03 03:58

The answer posted by Sekar, needs a little editing,

box-shadow:2px 2px 10px 10px #C9C9C9;
-webkit-box-shadow:2px 2px 10px 10x #C9C9C9;
-moz-box-shadow:2px 2px 10px 10px #C9C9C9;

this doesnot work on IE(I checked on IE8).

查看更多
欢心
5楼-- · 2020-06-03 04:01

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.

查看更多
何必那么认真
6楼-- · 2020-06-03 04:01

Below line worked for me. I used an image with dimensions 600x600.

-webkit-filter: drop-shadow(-10px 8px 30px #000) !important;
查看更多
一纸荒年 Trace。
7楼-- · 2020-06-03 04:02

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)
        ";
    }

查看更多
登录 后发表回答