如何使用JavaScript设置元素的最高位置?
要设置最高位置,请使用JavaScript中的top 属性。您可以尝试运行以下代码以使用JavaScript设置div的顶部位置-
示例
<!DOCTYPE html>
<html>
<head>
<style>
#myID {
position: absolute;
}
</style>
</head>
<body>
<button onclick="display()">Set Top Position</button>
<div id = "myID">
This is demo text! This is demo text!
</div>
<script>
function display() {
document.getElementById("myID").style.top = "100px";
}
</script>
</body>
</html>热门推荐
10 小寒健康祝福语大全简短
11 母亲说生日祝福语 简短
12 高考祝福语 简短12字
13 打游戏通关祝福语简短
14 新年祝福语简短句子
15 给医生简短新年祝福语
16 朋友药店开业祝福语简短
17 租房明天搬家祝福语简短
18 良师益友祝福语简短