maxHeight 사용 JavaScript의 속성을 사용하여 최대 높이를 설정합니다. 다음 코드를 실행하여 JavaScript로 요소의 최대 높이를 설정할 수 있습니다 -
예시
<!DOCTYPE html> <html> <head> <style> #box { width: 300px; background-color: gray; overflow: auto; } </style> </head> <body> <p>Click below to set Maximum height.</p> <button type="button" onclick="display()">Max Height</button> <div id="box"> <p>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.<p> <p>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.<p> <p>This is a div. This is a div. This is a div.<p> </div> <br> <script> function display() { document.getElementById("box").style.maxHeight = "70px"; } </script> </body> </html>