好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

css 利用 position + margin 实现固定盒子横向纵向居中的方法

m arg in:auto; + pos IT ion: absolute; 上下左右:0
一看 demo 就懂的啦

<!DOCTY PE  ht ML >
<html>

<head>
	< ;m eta http-equiv="Content -t ype" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<meta n am e="viewport" content="initial -s cale=1.0, maximum-scale=1.0, user-scalable=no" />
	<title> 利用  position + mar gin  实现固定 盒子 横向纵向居中</title>
	<style>
		body * {
			outline: 1px  # ff0000 solid;
		}

		.father {
			width: 500px;
			h ei ght: 300px;
			position: relative;
		}

		.father .son {
			width: 180px;
			height: 140px;
			/*  */
			position: absolute;
			right: 0;
			bottom: 0;
			top: 0;
			left: 0;
			margin: auto;
		}
	</style>
</head>

<body>
	<div class="father">
		<div class="son">margin:auto + 上下左右:0</div>
	</div>
</body>

</html>

//end

到此这篇关于css 利用 position + margin 实现固定盒子横向纵向居中的方法的 文章 就介绍到这了,更多相关css固定盒子横向纵向居中内容请搜索以前的文章或继续浏览下面的相关文章,希望大家以后多多支持!

总结

以上是 为你收集整理的 css 利用 position + margin 实现固定盒子横向纵向居中的方法 全部内容,希望文章能够帮你解决 css 利用 position + margin 实现固定盒子横向纵向居中的方法 所遇到的问题。

如果觉得 网站内容还不错, 推荐好友。

查看更多关于css 利用 position + margin 实现固定盒子横向纵向居中的方法的详细内容...

  阅读:19次