【发布时间】:2020-01-08 18:09:47
【问题描述】:
我有一个有大小的菜单,当您单击按钮时,它会将宽度减小到 50 像素
我会有一个带有按钮和图标的菜单,当点击按钮时只会出现图标
但是我很难减少我的 div 的宽度以及它如何在语义网格上工作
代码:
function Menu() {
const [open, setOpen] = useState(true); // declare new state variable "open" with setter
const handleClick = e => {
e.preventDefault();
setOpen(!open);
};
return (
<Grid style={{background: '#eee'}}>
<Grid.Column computer={2} tablet={4} mobile={5} style={{background: '#000', padding:'0', height:'100vh'}}>
<div style={{background:'#000', width:'100%', height:'100%'}}>
</div>
</Grid.Column>
<Grid.Column width={14} style={{background: '#eee', padding:'0'}}>
<Button icon onClick={handleClick}>
<Icon name="align justify" />
</Button>
</Grid.Column>
</Grid>
);
}
css:
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
#root,
.App,
.ui.grid{
height: 100vh !important;
margin: 0 !important;
padding:0 !important;
}
【问题讨论】:
-
这是你想要的吗? codesandbox.io/s/goofy-silence-63gi8
-
请让我知道您是否想要一些特定的东西来做到这一点。
-
是的,就是这样,但我正在为网格绞尽脑汁,因为内容不仅要适合菜单
-
太棒了!!!...让我在这里发布答案...同时发布关于另一个问题的答案stackoverflow.com/a/59639573/5783700
-
是啊,非常感谢
标签: css reactjs semantic-ui