简体   繁体   English

为什么 Internet Explorer 8 中没有底部填充?

[英]Why there is no bottom padding in Internet Explorer 8?

Why in the following code there is no bottom padding in Internet Explorer 8?为什么在以下代码中 Internet Explorer 8 中没有底部填充?

HTML: HTML:

<div id="wrapper">
    <div class="a">Hello</div>
    <div class="a">Stack</div>
    <div class="a">Overflow</div>
</div>

CSS: CSS:

#wrapper {
    border: 1px solid red;
    padding: 10px;
    height: 30px;
    overflow: auto;
}
.a {
    border: 1px solid black;
}

Any workarounds for browser compatibility?浏览器兼容性的任何解决方法?

browser interpretation of the specs?浏览器对规格的解释?

A value of 'scroll' would tell UAs that support a visible scrolling mechanism to display one so that users could access the clipped content. 'scroll' 的值将告诉支持可见滚动机制的 UA 显示一个,以便用户可以访问剪辑的内容。

Taken literally that means they, the browsers, can please themselves and they only have to provide access to the content not the padding or borders;)从字面上看,这意味着他们,浏览器,可以取悦自己,他们只需要提供对内容的访问,而不是填充或边框;)

a compatible workaround:兼容的解决方法:

#scroller {
    border: 1px solid red;
    height: 50px;
    overflow: auto;
}

.wrap {padding: 10px;}

.a {
    border: 1px solid black;
}

HTML: HTML:

<div id="scroller">
  <div class="wrap">
    <div class="a">Hello</div>
    <div class="a">Stack</div>
    <div class="a">Overflow</div>
  </div>
</div>

How about going dirty?弄脏了怎么办? (Heck, I'm a programmer, not a designer lol). (哎呀,我是程序员,不是设计师哈哈)。

<style type="text/css">
#wrapper {
    border: 1px solid red;
    padding: 10px;
    height: 30px;
    overflow: auto;
}
.a {
    border: 1px solid black;
}
.b {
    display:none;
}
</style>

<!--[if IE 8]>
<style type="text/css">
.b {
    display:block;
    height: 10px;
}
</style>
<![endif]-->

And:和:

<div id="wrapper">
    <div class="a">Hello</div>
    <div class="a">Stack</div>
    <div class="a">Overflow</div>
    <div class="b"></div>
</div>

:D :D

add display: block;添加显示:块; to #wrapper {} - I had exactly the same issue, with this added padding-bottom started to work properly under IE8 and other browsers was not affected (keep the proper output)到 #wrapper {} - 我遇到了完全相同的问题,添加的 padding-bottom 在 IE8 下开始正常工作,其他浏览器不受影响(保持正确的输出)

You can add a pseudo-element «after» only for IE8:您只能为 IE8 添加伪元素 «after»:

<!--[if IE 8]>
<style type="text/css">
#wrapper:after {
    content: '';
    display: block;
    height: 10px;
}
</style>
<![endif]-->

Read this post i think it will be helpful it did the trick for me阅读这篇文章,我认为它对我有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM