import './demo8.css'; import Grid from '..'; import React from 'react'; import ReactDOM from 'react-dom'; const { Row, Col } = Grid; const breakpoints = { xxs: 320, xs: 480, s: 720, m: 990, l: 1200, xl: 1500, }; class Demo extends React.Component { componentDidMount() { window.addEventListener('resize', this.handleResize); this.handleResize(); } componentWillUnmount() { window.removeEventListener('resize', this.handleResize); } handleResize = () => { const row = ReactDOM.findDOMNode(this.refs.fixCol) as HTMLElement; let point = ''; const innerWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; const keys = Object.keys(breakpoints); for (let i = 0; i < keys.length; i++) { const width = breakpoints[keys[i]]; const nextWidth = breakpoints[keys[i + 1]]; if (innerWidth > width && (innerWidth < nextWidth || !nextWidth)) { point = keys[i]; break; } } if (point) { row.innerHTML = `${breakpoints[point]}px`; } }; render() { return (
Default
100%
Set fixed to true
Set fixedWidth to 's'
720px
); } } ReactDOM.render(, document.getElementById('grid-demo-8'));