html - ie7 子 block 元素扩展并忽略父填充

标签 html css

我很难弄明白这一点。

我在另一个具有底部填充(父元素)的 block 元素中有一个 block 元素。子元素将其高度扩展 100%,同时吃掉/重叠父元素的底部填充,就好像根本没有填充一样。

什么可能触发此行为?

这是 HTML 代码:

<span class="boxTop">
    <span class="boxBottom">
        <span class="boxLeft">
            <span class="boxRight">
                <span class="box">
                    Content goes here
                </span>
            </span>
        </span>
    </span>
</span>

这是 CSS:

.infoBox .boxTop {
padding:20px 0 0 0;
display:block;
background:transparent url(images/infobox-top.png) repeat-x 0 0;
}
.infoBox .boxBottom {
padding:0 0 20px 0;
display:block;
background:transparent url(images/infobox-bottom.png) repeat-x 0 bottom;
}
.infoBox .boxLeft {
padding:0 0 0 20px;
display:block;
background:transparent url(images/infobox-left.png) repeat-y left 0;
}
.infoBox .boxRight {
padding:0 20px 0 0;
display:block;
background:transparent url(images/infobox-right.png) repeat-y right 0;
}

这是它在 ie7 中的样子:

这里是 boxBottom:http://img.photobucket.com/albums/v466/nemesis2k4/Forum%20Posts/boxbottom.jpg

这里是 boxLeft 和 boxRight,它们都在扩展和重叠/忽略 boxBottom 的填充: http://img.photobucket.com/albums/v466/nemesis2k4/Forum%20Posts/boxleft.jpg http://img.photobucket.com/albums/v466/nemesis2k4/Forum%20Posts/boxright.jpg

最佳答案

试试这个。我假设您想将 .boxRight 和 .boxLeft 放在 .boxBottom

HTML

<span class="infoBox"> <!--InfoBox Start-->
 <span class="boxTop"> <!--boxTop Start-->
 </span>               <!--boxTop End-->

 <span class="boxBottom"> <!--boxBottom Start-->
  <span class="boxLeft">  <!--boxLeft Start-->
  </span>                 <!--boxLeft End-->

  <span class="boxRight"> <!--boxRight Start-->
  </span>                 <!--boxRight End-->
 </span>                  <!--boxBottom End-->
</span>                   <!--InforBox End-->

CSS

.boxTop
{
display: block;
padding-bottom: 20px;
}

.boxBottom
{
display: block;
padding-top: 20px;
}

关于html - ie7 子 block 元素扩展并忽略父填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5856678/

相关文章:

java - 如何在网页上突出显示文本 - 严格定时 - 没有 Flash 的卡拉 OK。选择什么技术?

html - css中的水平滚动

php - 我只需要从另一个 html/php 页面导入表格

html - 我们如何去除两里之间的空间?

javascript - 阻止在移动设备上查看我的网站

html - 仅将元素移动到具有负边距的左侧,但元素也会移动到顶部

javascript - 垂直拉伸(stretch)背景图像而不是按比例拉伸(stretch),而不仅仅是覆盖 - 这可以实现吗?

css - HTML 5 浏览器和分辨率与 XHTML 的兼容性

css - 弹出窗口没有获得完整的导航栏大小

html - 将背景图像带到前台。可能与否?