如何使一个固定的div元素与css?

问题描述:

我需要创建 div 元素,它始终位于所有其他元素之上的右上角。

I need to create div element that would always be at the top right corner above all other elements

这是我尝试的

<div id="prompt" style=" height:50px;  width:50px;  background: #F00;  position: fixed;  top: 150px;    margin-left: 948px; z-index: 9999">Test</div>



我需要它来处理 IE8

通过移除 margin-left:948px; 并添加 right:0px; ,您的 #prompt div将位于屏幕右侧IE 8和在主要的浏览器,我相信(火狐确认)。

By removing margin-left: 948px; and adding right: 0px;, your #prompt div will position itself on the right side of the screen in IE 8 and in major browsers as well I believe (Firefox confirmed).