I need to create div
element that would always be at the top right corner above all other elements
Here is what I tried
<div id="prompt" style=" height:50px; width:50px; background: #F00; position: fixed; top: 150px; margin-left: 948px; z-index: 9999">Test</div>
I need it to work with IE8
, but it is not working.
You need to set left: 0;
or use right
without margin-left
.
For positioning in the top-right corner:
<div id="prompt" style="height:50px; width:50px; background: #F00; position: fixed; top: 150px; right: 0; z-index: 9999">Test</div>
Change the right value as you see fit (i.e. if you want the element an equal distance from the top as it is from the right, make the right value 150px
)
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).