我想使用document.style.position
将文本标签移动到自定义位置我有这个脚本:
var clickHandler = function() {
var doc = document.getElementById("result");
doc.style.visibility = "visible";
doc.style.color = "#ff0000";
doc.style.position = "left:150px";
}
(看this作为位置教程)。哪里错了?
答案 0 :(得分:4)
你想要的是:
doc.style.position = "absolute"; // or "relative" or "fixed" or etc
doc.style.left = "150px";
请参阅:https://developer.mozilla.org/en-US/docs/Web/CSS/position
答案 1 :(得分:4)
检查此代码:
var clickHandler = function() {
var doc = document.getElementById("result");
doc.style.visibility = "visible";
doc.style.color = "#ff0000";
doc.style.left= "150px";
}