固定位置DIV在Chrome和Safari中运行良好,但在IE11中无效

时间:2014-07-18 15:37:36

标签: html css fixed

这个CSS导致Button被锚定在我们网站的屏幕底部。向上或向下滚动时,按钮保持固定在页面底部。在IE中,它只是将按钮呈现在DIV代码所在的位置,而不是将其浮动并将其锚定到浏览器的底部。 Chrome和Safari都会在浏览器窗口的右下角显示按钮。我已经阅读了几篇文章并尝试了不同的CSS设置,但似乎无法得到它。任何帮助将不胜感激。谢谢!

<style type="text/css">
    div[id="bottomButton"] {
        position: fixed;
        bottom: -20px;
        right: 45px;
        border: none;
        z-index: 50;
        border-color: transparent;
        width: inherit;
    }
</style>

1 个答案:

答案 0 :(得分:1)

您的代码中缺少HTML doctype。请尝试以下代码。

<!DOCTYPE html>
<html>
<head>
<script>
</script>
<style type="text/css">
    #bottomButton {
        position: fixed;
        bottom: -20px;
        right: 45px;
        border: none;
        z-index: 50;
        border-color: transparent;
        width: inherit;
    }
</style>
</head>
<body>
<div id="bottomButton">
<button>mybutton</button>
</div>

</body>


</html>