Skip to main content

css-布局

居中布局

方法一:flex布局

.vertical-container {
height: 300px;
display: flex;
align-items: center;
justify-content: center;
}

方法二:设置margin

.father-ele {
width:100vw;
margin: 0 auto;
.son-ele{
//注意子元素宽度小于父元素宽度。
width:90vw;
}
}

左右布局

方法一:使用flex

.main{
display:flex;
flex-direction:column;
.left-box{
flex:1;
}
.right-box{
flex:1;
}
}