如何使用center或者div的align属性让你的html button本身居中

tech2025-12-26  7

切记,须在父元素上添加居中属性,如下:

<html> <body> <center><button onClick="myClick()">Hello Word</button></center> <script> function myClick() { alert("123"); } </script> </body> </html>

或者:

<html> <body> <div align="center"><button onClick="myClick()">Hello Word</button></div> <script> function myClick(){ alert("123"); } </script> </body> </html>

 

最新回复(0)