简体   繁体   English

固定位置DIV在Chrome和Safari中可以正常使用,但在IE11中则不能

[英]Fixed position DIV that works fine in Chrome and Safari but not in IE11

This CSS causes a Button to be anchored at the bottom of the screen of our website. 此CSS导致一个Button锚定在我们网站的屏幕底部。 The button stays anchored to the bottom of the page when scrolling up or down. 向上或向下滚动时,该按钮将停留在页面底部。 In IE, it just renders the button right where the DIV code is located instead of floating it and anchoring it to the bottom of the browser. 在IE中,它只是将按钮呈现在DIV代码所在的位置,而不是将其浮动并固定在浏览器底部。 Chrome and Safari both show the button at the bottom right of the browser window. Chrome和Safari都在浏览器窗口的右下方显示该按钮。 I have gone through several articles and tried different CSS settings but cannot seem to get it. 我浏览了几篇文章并尝试了不同的CSS设置,但似乎无法理解。 Any help would be greatly appreciated. 任何帮助将不胜感激。 Thanks! 谢谢!

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

you are missing HTML doctype in your code. 您的代码中缺少HTML文档类型。 Try below code. 尝试下面的代码。

<!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>

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

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