码迷,mamicode.com
首页 > Web开发 > 详细

css——利用translate让元素居中

时间:2020-01-10 18:30:42      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:nsf   ati   span   bsp   元素   居中   pre   nbsp   orm   

父元素:

position: relative;

 

居中元素:

position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);

css——利用translate让元素居中

标签:nsf   ati   span   bsp   元素   居中   pre   nbsp   orm   

原文地址:https://www.cnblogs.com/linjiangxian/p/12177509.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!