html笔记

2018-08-13  本文已影响0人  paperss

一.div内元素垂直水平居中
code:https://codepen.io/piedpiperr/pen/zmYoRx

.iteams_center{
            display:flex;
            justify-content:center;
            align-items:center;
 }
<div class="wp">
    <div class="box size">123123</div>
</div>

.wp {
    border: 1px solid red;
    width: 300px;
    height: 300px;
    position: relative; 
}

.box {
    width: 100px;height: 100px;
    background: green;

   position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
上一篇 下一篇

猜你喜欢

热点阅读