那么如何将<Table>
置于<div>
内的固定宽度中心,当浏览器变小时,只需让滚动条显示并保持<Table>
& #39;固定宽度?谢谢
这就是我所拥有的:
<div>
<Table>
<TableBody style={{width: 1000}}>
<TableRow>
<TableRowColumn>Row 1</TableRowColumn>
<TableRowColumn>Content 1</TableRowColumn>
</TableRow>
<TableRow>
<TableRowColumn>Row 2</TableRowColumn>
<TableRowColumn>Content 2</TableRowColumn>
</TableRow>
</TableBody>
</Table>
<div/>
修改
答案 0 :(得分:0)
以下是一个示例:https://jsfiddle.net/mzt8pvtu/3/
HTML:
<div id="container"></div>
JS:
const { Table, TableHeader, TableBody, TableRow, RaisedButton, TableRowColumn, TableHeaderColumn, MuiThemeProvider, getMuiTheme } = MaterialUI;
class Example extends React.Component {
render() {
return (
<div style={{ width: '100%' }}>
<Table style={{ width: 400, margin: 'auto' }}>
<TableHeader>
<TableRow>
<TableHeaderColumn>ID</TableHeaderColumn>
<TableHeaderColumn>Name</TableHeaderColumn>
<TableHeaderColumn>Status</TableHeaderColumn>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableRowColumn>1</TableRowColumn>
<TableRowColumn>John Smith</TableRowColumn>
<TableRowColumn>Employed</TableRowColumn>
</TableRow>
<TableRow>
<TableRowColumn>2</TableRowColumn>
<TableRowColumn>Randal White</TableRowColumn>
<TableRowColumn>Unemployed</TableRowColumn>
</TableRow>
<TableRow>
<TableRowColumn>3</TableRowColumn>
<TableRowColumn>Stephanie Sanders</TableRowColumn>
<TableRowColumn>Employed</TableRowColumn>
</TableRow>
<TableRow>
<TableRowColumn>4</TableRowColumn>
<TableRowColumn>Steve Brown</TableRowColumn>
<TableRowColumn>Employed</TableRowColumn>
</TableRow>
</TableBody>
</Table>
</div>
);
}
}
const App = () => (
<MuiThemeProvider muiTheme={getMuiTheme()}>
<Example />
</MuiThemeProvider>
);
ReactDOM.render(
<App />,
document.getElementById('container')
);