Expanding cells in CSS grid layout
问题 I have the following HTML/CSS .main { display: grid; grid-template-columns: 2fr 1fr; } /* The following is not essential - for decoration purposes only */ .left { background-color: green; } .right { background-color: orange; } <div class="main"> <div class="left">Left</div> <div class="right">Right</div> </div> Now, sometimes, and depending on the div with class main , sometimes I do not have the div with the class right (in other words, the html might look like this .main { display: grid;