How to modify grid-template-areas with javascript

前端 未结 3 695
南笙
南笙 2020-12-20 12:13

I have been trying to modify grid-template-areas with javascript. I found a property in the css properties list (elem.style) in the DOM called:

3条回答
  •  自闭症患者
    2020-12-20 13:09

    with styled-components

    
    const Grid = styled.div`
      width: 100px;
      height: 100px;
      background-color: red;
      display: grid;
      grid-template-areas: ${(props) => props.areas 
      ? props.areas.reduce((acc, str) => (acc += `${"'" + str + "'" + "\n"}`), ``) + ";" 
      : "none"};
      grid-template-columns: 1fr 1fr 1fr;
      grid-template-rows: 1fr 1fr 1fr;
    `
    
    const StyledGrid = () => (
      
    )
    
    
    

提交回复
热议问题