简体   繁体   中英

css grid layout column

I am trying to create a layout with 5 columns using css grid. The first and the last columns should have white space.
I try to create it but somehow it turns out to be three rows instead of columns.

 .grid_container{ grid-template-columns: 1fr 2fr 4fr 2fr 1fr; grid-template-areas: ". ABC ." } #column1 { grid-area: A; background:red; padding: 100px; } #column2 { grid-area: B; background:blue; } #column3{ grid-area: C; background: orange; } 

I have the 5 columns but the first and the fifth columns should have whitespace.

You're missing the most important property display: grid . The example in CodePen Grid columns . Cheers, sigfried.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM