Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何使div元素固定?_Html_Css_Internet Explorer 8 - Fatal编程技术网

Html 如何使div元素固定?

Html 如何使div元素固定?,html,css,internet-explorer-8,Html,Css,Internet Explorer 8,我需要我的id=prompt1的被固定在所有其他元素之上。因此,每当我滚动窗口时,仍然可以看到。在我的html中,我不工作。(IE8) $(函数(){ 对于(i=0;i您的代码可以正常工作。div刚刚移到右侧。取决于分辨率-您可能看不到它 关键属性只是position=fixedIE 8使用fixed-签出,或谷歌“ie8 position:fixed”你已经有了一个与此非常类似的问题-以何种方式不起作用?当我向下滚动窗口时,在这个问题中,@Lee,我没有发布完整的html,因此我没有得到一个

我需要我的id=prompt1的
被固定在所有其他元素之上。因此,每当我滚动窗口时,仍然可以看到
。在我的
html
中,我不工作。(IE8


$(函数(){

对于(i=0;i您的代码可以正常工作。
div
刚刚移到右侧。取决于分辨率-您可能看不到它


关键属性只是
position=fixed
IE 8使用
fixed
-签出,或谷歌“ie8 position:fixed”

你已经有了一个与此非常类似的问题-以何种方式不起作用?当我向下滚动窗口时,在这个问题中,
@Lee,我没有发布完整的
html
,因此我没有得到一个好的答案。我试图删除它,但它不允许我认为你应该编辑第一个问题,而不是开始一个新的问题,因为我是其中一个问题不管怎样,它们最终可能会被关闭。谢谢,正确的答案就在那里:
<html>
<head> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"></script> 
<script>
$(function() {
for (i=0; i<30; i++) {
$("#test").append("<TABLE border='solid'>" + 
   "<TR>" + 
      "<TD>Data 1</TD>" + 
      "<TD>Data 2</TD>" + 
   "</TR>" + 
   "<TR>" + 
      "<TD>Data 3</TD>" + 
      "<TD>Data 4</TD>" + 
   "</TR>" + 
"</TABLE>"); 
}
}); 
</script>
</head>

<body> 
<div id='test' style="float: left; width: 100px;" ></div> 
<div id="prompt1" style="float: left; width: 200px; height:50px; width:50px; background: grey; color: white;  position: fixed; top: 150px; right: 0; z-index: 9999">Prompt1</div>
</body>
</html>