如何使材料UI的组件响应?

发布于 2025-02-11 02:25:38 字数 1197 浏览 1 评论 0 原文

我对材料UI是相对较新的,并且已经设计了类型搜索的文本字段。我希望它能迅速响应。但是我无法在屏幕尺寸的屏幕尺寸中渲染宽度小于423

<Box
  sx={{ flexGrow: 1 }}
  m={5} pt={5}
  display="flex"
  justifyContent="flex-end"
  alignItems="flex-end"
>
  <Grid item sx={{ flexGrow: 1 }} spacing={{ xs: 1, md: 2,lg:2}} columns={{ xs: 2, sm: 2, md: 12 ,lg: 22}} display="flex"
justifyContent="center"
alignItems="center" marginLeft={8} marginRight={1} mt={4} width='100%'>
    <SearchIcon style={{ coSelf: "center", margin: "5px" }} />
    <TextField
      id="standard-search"
      label="Search for a company..."
      type="search"
      variant="standard"
      textAlign="center"
      fullWidth

    />
  </Grid>
  <Button onClick={() => setLight((prev) => !prev)} variant="contained" color="primary" sx={{ height: 40 }}>
    <SettingsIcon/>
  </Button>
</Box>

“在此处输入图像描述”

任何帮助都将不胜感激。

I am relatively new to material UI and I have designed a text field of type search. I would like it to be responsive. But I am failing to render the textfield in screen sizes with width smaller than 423

<Box
  sx={{ flexGrow: 1 }}
  m={5} pt={5}
  display="flex"
  justifyContent="flex-end"
  alignItems="flex-end"
>
  <Grid item sx={{ flexGrow: 1 }} spacing={{ xs: 1, md: 2,lg:2}} columns={{ xs: 2, sm: 2, md: 12 ,lg: 22}} display="flex"
justifyContent="center"
alignItems="center" marginLeft={8} marginRight={1} mt={4} width='100%'>
    <SearchIcon style={{ coSelf: "center", margin: "5px" }} />
    <TextField
      id="standard-search"
      label="Search for a company..."
      type="search"
      variant="standard"
      textAlign="center"
      fullWidth

    />
  </Grid>
  <Button onClick={() => setLight((prev) => !prev)} variant="contained" color="primary" sx={{ height: 40 }}>
    <SettingsIcon/>
  </Button>
</Box>

enter image description here

enter image description here

Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

短叹 2025-02-18 02:25:38

看来您的搜索组件是渲染的,但藏在股票市场图表标题后面,因为它的屏幕尺寸较小。如果将其作为固定位置,请尝试将其更改为相对位置,或删除/减少其中的文本,以便快速测试变短,并可能显示搜索成分。

Seems your search component is rendered but hiding behind the Stock Market Charting header as it gets longer in smaller screen sizes. If you have it as a fixed position try changing it to relative position, or remove/reduce the text inside it so it gets shorter for a quick test and might reveal the search component.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文