.father{ display: flex; align-items:center; justify-content: center; height:100vh; } #canvas{ background: linear-gradient(red, blue); /* 标准的语法 */ display: flex; }