x
 
<!DOCTYPE html>
<html>
<body>
<p>请在下面的列表中选择一个 position 值来更改 div 的位置。</p>
<div id="myDiv" style="top:50px;left:100px;">我是 div 元素。</div>
<select onchange="myFunction(this);" size="5">
  <option>absolute
  <option>fixed
  <option>static
  <option>relative
  <option>sticky
</select>
<script>
function myFunction(x) {
  var whichSelected = x.selectedIndex;
  var posVal = x.options[whichSelected].text;
  var elem = document.getElementById("myDiv");
  elem.style.position = posVal;
}
</script>
</body>
</html>