3

我遇到了一个我无法解决的问题,当我添加Position:relative;到一个 div 时,它会出现一个白色边框,或者像图像中的额外空间在此处输入图像描述

如果我删除 Position:relative;边框移动到也有的父级, Position:relative;这仅在 IE8 上。标记:

<div class="content clearfix">
    Some content goes here
         <div class="block">
               <div class="block_content" style="display: block;">
                 Some content goes here
              </div>
          </div>
 </div>

CSS:

.content {
min-height: 100%;
height: 100%;
position: relative;
width:100%;
background-color:#ebebeb;
}
.block_content {
display:none;
position:relative;
margin: 25px 20px 15px 20px;
}
.block{
      overflow:hidden;
    width:58%;
    padding-bottom:60px;
float:right;
position:relative;
margin-right:10%;
background: rgb(222,222,222); /* Old browsers */
background: -moz-linear-gradient(top,  rgba(222,222,222,1) 0%, rgba(255,255,255,1) 0%, rgba(222,222,222,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(222,222,222,1)), color-stop(0%,rgba(255,255,255,1)), color-stop(100%,rgba(222,222,222,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  rgba(222,222,222,1) 0%,rgba(255,255,255,1) 0%,rgba(222,222,222,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  rgba(222,222,222,1) 0%,rgba(255,255,255,1) 0%,rgba(222,222,222,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  rgba(222,222,222,1) 0%,rgba(255,255,255,1) 0%,rgba(222,222,222,1) 100%); /* IE10+ */
background: linear-gradient(to bottom,  rgba(222,222,222,1) 0%,rgba(255,255,255,1) 0%,rgba(222,222,222,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#dedede', endColorstr='#dedede',GradientType=0 ); /* IE6-9 */

            box-shadow: 6px 6px 14px #333333;
        -moz-box-shadow:6px 6px 14px #333333;
    -webkit-box-shadow: 6px 6px 14px #333333;
    }

演示链接:http ://bank.benseno.com.tr/Sunus.html 任何帮助表示赞赏

4

3 回答 3

3

好吧,好吧,好吧,我想我知道那个奇怪的边界是从哪里来的。

出自那一段:

.maroon:before {
    border: 4px solid #FFFFFF;
    bottom: 0;
    content: "";
    display: block;
    left: 0;
    position: absolute; 
    right: 0;
    top: 0;
    z-index: -1;
}

如果您删除content:"";,则不再看到该边框。

似乎 IE8 让父母一团糟。因此,如果您更改父级position:relative或删除它,IE8 会将此样式应用于前一个relative元素。我不知道这是否适用于filter你申请实现轮换的东西......

抱歉信息不完整,至少我们可以定位问题出在哪里...我继续研究,但现在也许您或其他用户知道这一点,可以帮助解决它。

于 2013-04-24T15:09:33.707 回答
1

由于 Web 浏览器以非常特殊的方式处理默认 CSS 属性,因此在开始开发之前重置 CSS 始终是一个好习惯。在我的测试中,我能够应用 Eric Meyers 的重置 css 技术解决问题,但重要的是要注意它在提供的代码是文档中唯一存在的代码的环境下工作。

查看您提供的示例网站,我可以看到您已经使用了 CSS 重置解决方案,但您没有使用在 HTML 5 页面(如该页面)上考虑的 CSS 重置。所以,我建议你改用 HTML5 Doctor CSS Reset。它基于 Eric Meyer 的解决方案,您可以在这里获得:http ://www.cssreset.com/

于 2013-04-24T14:04:30.357 回答
1

The problem lies with this line in layout.css (line 480):

.maroon:before{
    border: 4px solid #FFF;
    bottom: 0;
    content: "";
    display: block;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    z-index: -1;
}

Remove the border and content, or change the class.

于 2013-04-24T15:10:52.690 回答