如何让DIV固定在页面的某个位置

如题所述

给他的css样式里面加一个属性 position:aboslute;其实你可以看看position的几个值如aboslute/relative/fixed,这几个都是比较常用的定位。
温馨提示:内容为网友见解,仅供参考
第1个回答  推荐于2016-08-12
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>悬浮块</title>
<style type="text/css">
div.demo{
border:1px solid #CCC;background:red;
position:fixed;height:100px;width:100px;
z-index:100000;left:100px;top:100px;
}
</style>
</head>
<body>
<div style="height:2000px;">
<div class="demo">sdfsfsdfsf</div>
</div>
</body>
</html>本回答被提问者和网友采纳
相似回答