如何设置元素是否由用户使用JavaScript调整大小?
使用resize属性设置元素是否可由用户调整大小。
示例
您可以尝试运行以下代码来设置元素是否可由用户使用JavaScript调整大小-
<!DOCTYPE html>
<html>
<head>
<style>
#box {
width: 350px;
overflow: auto;
background-color: orange;
border: 3px solid red;
}
</style>
</head>
<body>
<p>Click to set the right position.</p>
<button type = "button" onclick = "display()"> Set Right Position </button>
<div id = "box">
<p>This is a div. This is a div. This is a div. This is a div.<p>
<p>This is a div. This is a div. This is a div. This is a div.<p>
<p>This is a div. This is a div. This is a div. This is a div.<p>
</div>
<br>
<br>
<script>
function display() {
document.getElementById("box").style.resize = "both";
}
</script>
</body>
</html>