微信二维码
微博二维码
qq号二维码

【html+css】简述居中

夏磊银 2020-09-09 WEB前端 200人浏览
简述你所掌握的居中,web面试中常出现
5个回答
黄庆峰
水平居中:text-align:center 垂直居中:line-height margin:0 auto
  2020-09-09
李永春
块元素:margin:0 auto; text-align:center
  2020-09-09
李子行
css:1. margin 0 auto;
2. text-align:center;文字居中
3. 将要居中的标签设置为 display:inline-block,然后将父级添加text-align:center;
4.父级添加相对定位,将居中标签绝对定位 position:absolute :top:50%,left:50%;然后magin-top: -height/2 margin-left: -width/2
  2020-09-09
王聪
1 . margin 0 auto ;
2 . text-align:center ;
3 . display:inline-block;父级加 text-align:center;
4 . 绝对定位居中:在标签父级上写position:relative; 子级写 position:absolute; 然后给子级加left: 50%; margin-left:-50px;
  2020-09-09
丁凯
1.左右外边距margin 设置为 auto;
2.父级css添加text-align:center;子级display: inline-block;
3. position:absolute; top:50%; left:50%; margin-top: 负的自身的一半; margin-left: 负的自身的一半;
4. width: 100%; height: 100%; transform: scale(0.5);
5. display:flex; justify-content:center;
6. transform:translate(50%,50%); margin-top: 负的自身的一半; margin-left: 负的自身的一半;
回答已被采纳   2020-09-10
分享到: