요소를 수평으로 정렬하려면 cssFloat 재산.
예시
다음 코드를 실행하여 JavaScript로 요소의 수평 정렬을 설정할 수 있습니다 -
<!DOCTYPE html> <html> <body> <img id="myID" src="https://www.tutorialspoint.com/videotutorials/images/tutor_connect_home.jpg" width="300" height="300"> <p>This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. </p> <button type="button" onclick="display()">Align Horizontally</button> <script> function display() { document.getElementById("myID").style.cssFloat = "right"; } </script> </body> </html>