为什么在Firefox和Chrome上工作时,此CSS代码在IE 10中不起作用

Mehrandvd

这段代码在Firefox和Chrome上运行正常,但在IE 10上却无法正常工作。蓝色部分在IE 10上的布局不正确

我认为问题在于:

.main-scroll {
    position: relative;
    height:100%;
    width: 100%;
    border-color: blue;
    border-style:solid;
    overflow-y: scroll;
}  

height: 100%似乎无法正常工作。据我所知,所有使用的样式在HTML 5.0和CSS 3.0中都是有效的。

问题:那么,为什么此代码无法在IE 10上正常工作,解决方法是什么?

吉尔达斯·坦博

将#body设置为相对位置

#body {
    height: 100px;
    width: 200px;
    position:relative;/*so that the children can habe an absolute position*/
}

接着

.main-scroll {
    position: absolute;
    height:100%;
    width: 100%;
    border-color: blue;
    border-style:solid;
    overflow-y: scroll;
}

演示:http : //jsfiddle.net/8Vu92/3/

我不知道您要做什么,但是如果您只想要蓝色和红色,则可以使用阴影框

演示:http : //jsfiddle.net/8Vu92/4/

<section class="main">
    This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content.
</section>

的CSS

.main {
    height: 100px;
    width: 200px;
    position:relative;
    overflow:auto;
    border:4px solid blue;
    box-shadow:0 0 0 4px red;
    padding: 10px;
    box-sizing:border-box;
}

更新:使用变换

#body {
    height: 100px;
    width: 200px;
}
.shell {
    height: 100%;
    width: 100%;
    display: table;
    border-color: red;
    border-style:solid;
}

.header-row {
    display: table-row;
    height: 40px
}
.main-row {
    height:100%;
    width: 100%;
    display: table-row;
    border-style:solid;
}
.main-scroll {
    height:120px;
    width: 100%;
    border-color: blue;
    border-style:solid;
    overflow-y: scroll;
    transform:translate3d(0,30px,0);
}
.main {
    display:block;
    height: 100%;
    width: 100%;
}

标记:

<div id="body">
    <div class="shell">
        <div class="header-row">
            This is the fixed height header
        </div>
        <div class="main-row">
            <div class="main-scroll">
                <section class="main">This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content.</section>
            </div>
        </div>
    </div>
</div>

演示:http : //jsfiddle.net/8Vu92/8/

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

为什么 css 在 Firefox 和 Chrome 中按预期工作时在 IE 中不起作用?

来自分类Dev

CSS在Chrome / Firefox中不起作用(渲染)但在IE10 / Edge中起作用

来自分类Dev

innerHTML在IE 10中不起作用

来自分类Dev

CSS代码在Firefox和IE中不起作用

来自分类Dev

CSS Flexbox在IE10中不起作用

来自分类Dev

在ie10中打印IFrame不起作用

来自分类Dev

渐变在IE 10/11中不起作用

来自分类Dev

在ie10中打印IFrame不起作用

来自分类Dev

身份流在IE 10中不起作用

来自分类Dev

渐变在IE-10中不起作用

来自分类Dev

为什么我的CSS颜色转换在IE10中不起作用?

来自分类Dev

为什么我的CSS颜色转换在IE10中不起作用?

来自分类Dev

为什么我的CSS在IE10中不起作用?

来自分类Dev

IE CSS不起作用,但在Firefox中起作用

来自分类Dev

removeEventListener在IE10中不起作用,在Chrome中工作

来自分类Dev

为什么此Javascript在Firefox中不起作用?

来自分类Dev

MongoDB查询在Node.js中不起作用 为什么此代码不起作用?

来自分类Dev

为什么HTML5输入的数字类型不起作用或在IE10中偶尔起作用

来自分类Dev

为什么此C代码在JavaScript中不起作用?

来自分类Dev

带有图片的SVG模式在IE 10和Firefox中不起作用

来自分类Dev

带有图片的SVG模式在IE 10和Firefox中不起作用

来自分类Dev

为什么$(window).load()在IE10中不起作用

来自分类Dev

为什么我的图标字体仅在Windows 8上的IE10中不起作用?

来自分类Dev

Javascript Array在IE7和更早版本中不起作用,但在IE10中起作用

来自分类Dev

jQuery funciton来显示消息在ie10中不起作用,但在chrome中起作用

来自分类Dev

在IE和Chrome中运行的代码在Firefox中不起作用

来自分类Dev

CSS -webkit-filter:灰度(0%)在IE 10和Safari中不起作用

来自分类Dev

Python IIS在FireFox中不起作用,但在IE和Chrome中起作用

来自分类Dev

jQuery在IE 10上不起作用

Related 相关文章

  1. 1

    为什么 css 在 Firefox 和 Chrome 中按预期工作时在 IE 中不起作用?

  2. 2

    CSS在Chrome / Firefox中不起作用(渲染)但在IE10 / Edge中起作用

  3. 3

    innerHTML在IE 10中不起作用

  4. 4

    CSS代码在Firefox和IE中不起作用

  5. 5

    CSS Flexbox在IE10中不起作用

  6. 6

    在ie10中打印IFrame不起作用

  7. 7

    渐变在IE 10/11中不起作用

  8. 8

    在ie10中打印IFrame不起作用

  9. 9

    身份流在IE 10中不起作用

  10. 10

    渐变在IE-10中不起作用

  11. 11

    为什么我的CSS颜色转换在IE10中不起作用?

  12. 12

    为什么我的CSS颜色转换在IE10中不起作用?

  13. 13

    为什么我的CSS在IE10中不起作用?

  14. 14

    IE CSS不起作用,但在Firefox中起作用

  15. 15

    removeEventListener在IE10中不起作用,在Chrome中工作

  16. 16

    为什么此Javascript在Firefox中不起作用?

  17. 17

    MongoDB查询在Node.js中不起作用 为什么此代码不起作用?

  18. 18

    为什么HTML5输入的数字类型不起作用或在IE10中偶尔起作用

  19. 19

    为什么此C代码在JavaScript中不起作用?

  20. 20

    带有图片的SVG模式在IE 10和Firefox中不起作用

  21. 21

    带有图片的SVG模式在IE 10和Firefox中不起作用

  22. 22

    为什么$(window).load()在IE10中不起作用

  23. 23

    为什么我的图标字体仅在Windows 8上的IE10中不起作用?

  24. 24

    Javascript Array在IE7和更早版本中不起作用,但在IE10中起作用

  25. 25

    jQuery funciton来显示消息在ie10中不起作用,但在chrome中起作用

  26. 26

    在IE和Chrome中运行的代码在Firefox中不起作用

  27. 27

    CSS -webkit-filter:灰度(0%)在IE 10和Safari中不起作用

  28. 28

    Python IIS在FireFox中不起作用,但在IE和Chrome中起作用

  29. 29

    jQuery在IE 10上不起作用

热门标签

归档