轻设计 / 轻生活 / 轻日记 / 轻梦想 === zhoumojianshe ===
© 优特良品&优特建站出品 | Powered by YOUTIY
苏ICP备13018047号-1
div 相对于屏幕水平垂直居中的方法
TAGS: 网页设计

 01 

前话

曾有多次要度娘搜索div相对于屏幕居中的方法,为了提高日后的工作效率,于是将方案记录于此。

 02 

图示

 03 

代码

 css 

<style>
	*{
		font-family: 思源黑体 CN;
		margin:0px;
		padding:0px;
	}
	.box {
		display: flex;
		justify-content: center; /* 水平居中 */
		align-items: center;     /* 垂直居中 */
		width: 100%;
		height: 100%;
	}
	.inner{
		border:2px solid gray;
		width:200px;
		height:50px;
		border-radius: 25px;
		text-align:center;
		line-height:50px;
		color:#EE3B3B;
		font-weight:bold;
		background:#F5F5F5;
		font-size:1.2em;
	}
</style>
 html 
<div class="box">
	 <section class="inner">周末の设计</section>
</div>
 04 

下载

https://pan.baidu.com/s/1kBbAQeK2NZyPd33MKySOQw


本文由周末简设原创出品,如需转载请注明出处
本文出处:http://www.youtiy.com/detail_474.html

周末
2019-09-30 14:29:26
标签云
网页设计 精致慢生活 感悟思语 我的旧年华
加偶微信