2019-02-06/Grid布局笔记

grid布局例子

html:


  
header
main
footer

css

.container{
  display: grid;
  grid-template-rows: 1fr 150px 1fr;
  grid-template-columns: 50px auto 50px;
  height: 200px;
  justify-items:center; //元素水平居中
  align-item:center;
  
  justify-content:center; //Grid整体网格水平居中
  align-content:center;
   
}

header{
  grid-row: 1;
  grid-column: 1 / span 3;
  background: red;

}

main{
  grid-row: 2;
  grid-column: 2 / span 2;
  background: green;
}

aside{
  grid-row: 2;
  grid-column: 1;
  background: yellow;
}

footer{
  grid-row: 3;
  grid-column: 1 / span 3;
  background: blue;
}

你可能感兴趣的:(2019-02-06/Grid布局笔记)