场景
2023年01月23日
场景一、两栏布局
场景背景: 实现一个左宽为200px
, 右宽自适应的两栏布局
场景解决: 通过 grid-template-columns: 200px auto
实现
实时编辑器
function Test(props) { const containerStyle = { width: '100%', height: '300px', backgroundColor: 'red', display: 'grid', gridTemplateColumns: '200px auto', } const leftStyle = { backgroundColor: "yellow" } const rightStyle = { backgroundColor: "blue" } return ( <div style={ containerStyle }> <div style={ leftStyle }></div> <div style={ rightStyle }></div> </div> ); }
结果
Loading...
场景二、三栏布局
场景背景: 实现一个左宽为200px
, 右宽为200px
, 中间自适应的三栏布局
场景解决: 通过 grid-template-columns: 200px auto 200px
实现
实时编辑器
function Test(props) { const containerStyle = { width: '100%', height: '300px', backgroundColor: 'red', display: 'grid', gridTemplateColumns: '200px auto 200px', } const leftStyle = { backgroundColor: "yellow" } const centerStyle = { backgroundColor: "green" } const rightStyle = { backgroundColor: "blue" } return ( <div style={ containerStyle }> <div style={ leftStyle }></div> <div style={ centerStyle }></div> <div style={ rightStyle }></div> </div> ); }
结果
Loading...