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

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

<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>

猜你喜欢

转载自blog.csdn.net/qq_42363090/article/details/108402842