(转载)设置 button 垂直、水平居中的样式(CSS)参考

该篇文章转载自:CSDN

<html>
	<head>
		<style>
		#div1 {
			width:100px;
			height:100px;
			border:1px black solid;
			
			text-align: center;
		}
		#div2 {
			width:100px;
			height:100px;
			border:1px black solid;
					
			display:flex;
			align-items:center;
			/* 水平居中把这个打开 */
			/* justify-content:center; */
		}
		</style>
	</head>
	<body>
		<div id="div1">
			<button>水平居中</button>
		</div>
		<div id="div2">
			<button>垂直居中</button>
		</div>
	</body>
</html>
posted @ 2021-06-27 10:00  摘叶飞镖  阅读(852)  评论(0)    收藏  举报