【问题标题】:image-shadow behind the main div主 div 后面的图像阴影
【发布时间】:2013-02-28 21:33:51
【问题描述】:

我有以下 HTML 源代码:

    <div id="page">
        <div id="header">
            <!-- end header div -->
        </div>
        <div id="dropdown">
       <!--navigator menu is here!-->
        </div>

    <div id="main">
 <!--main is here!-->
     </div>
       <div id="sidebar">
           <!--sidebar menu is here!--></div>
        <div id="footer">

        </div>
        <!-- end page div -->
    </div>
    <div id="leftshadow"></div>
    <div id="rightshadow"></div>
</body>

这是 CSS 源代码

/* html selectors ---- */

html, body {
    font-family: 'Arial Unicode MS';
    margin: 0;
    padding: 0;
    background-repeat: repeat-x;
    background-color: white;
    direction: rtl;
    font-size: 10.3pt;
}



/*page -----------*/
#page {
    width: 900px;
    padding: 0px;
    margin: 0 auto;
    direction: rtl;
    position: relative;
    z-index: 100;
    z-index: 5;
    background-image: url("images/bgimage.png");
}

#leftshadow {
    width: 100px;
    height: 900px;
    background-image: url("images/leftshadow.png");
    position: absolute;
    right: 1220px;
    z-index: none;
    top: -50px;
}

#rightshadow {
    width: 100px;
    height: 900px;
    background-image: url("images/rightshadow.png");
    position: absolute;
    right: 345px;
    z-index: none;
    top: -25px;
}


/* header ---------- */

#header {
    height: 110px;
    top: 0px;
    line-height: 30px;
    background-image: url("images/header.png");
    background-position-x: center;
    background-repeat: repeat-x;
}


/* main -------------- */



#main {
    line-height: 21px;
    font-family: arial;
    width: 625px;
    padding: 30px;
    position: relative;
    right: 205px;
    padding-bottom: 80px;
    direction: rtl;
    top: 42px;
    padding-right: 60px;
    min-height: 750px;

      text-align: justify;

}

通常我得到这个结果

但在 Internet-Explorer 我得到了这个结果

我知道如果我会插入

   <div id="leftshadow"></div>
         <div id="rightshadow"></div>

******这里是现场示例! http://lawb.co.il/******

进入#page Div问题可以解决,但唯一的问题是阴影在内容上,而不是在他后面

你能帮我解决这个问题吗?

希望得到帮助,谢谢!

【问题讨论】:

  • 你在使用 CSS 重置吗?
  • @KrisHollenbeck 什么是 CSS 重置?
  • 它将所有浏览器的 CSS 重置为零,因此它们都相同。默认情况下,所有浏览器都会在 HTML 元素上设置不同类型的填充和边距。强烈建议您每次创建新的 Web 项目时使用一个。它可以防止浏览器之间的许多布局不一致。 meyerweb.com/eric/tools/css/reset
  • @KrisHollenbeck 您好,感谢您的分析,我试过了,但还是不行,为什么?

标签: css internet-explorer position shadow


【解决方案1】:

在可以使用 CSS3 box-shadow 的情况下,为什么要使用图像来创建阴影?

如果您打算使用这种方法,我会像这样更改您的 HTML 结构:

<div id="page">
    <div id="leftshadow"></div>
    <div id="header">
        <!-- end header div -->
    </div>
    <div id="dropdown">
        <!--navigator menu is here!-->
    </div>

    <div id="main">
        <!--main is here!-->
    </div>
    <div id="sidebar">
        <!--sidebar menu is here!-->
    </div>
    <div id="footer">
        <!-- footer -->
    </div>
    <!-- end page div -->
    <div id="rightshadow"></div>
</div>

然后将右阴影 div 向右浮动,将左阴影 div 向左浮动。您很可能会看到不一致的地方,因为 您没有使用重置,并且东西是相对定位的。如果在 #page 容器内不需要绝对定位,您真的不需要将所有内容定位为相对位置和阴影。

【讨论】:

  • 我使用图像,因为它不是常规阴影,在 css 阴影中创建它非常复杂(这是图像:lawb.co.il/images/leftshadow.png)我尝试使用 CSS 重置 - 并插入 shaows div 到页面 div 中,但是页面 Div 仍然在它们之上...
猜你喜欢
  • 2018-08-20
  • 1970-01-01
  • 1970-01-01
  • 2017-02-14
  • 2023-02-02
  • 2012-03-28
  • 1970-01-01
  • 2023-03-20
  • 1970-01-01
相关资源
最近更新 更多