javascript - 添加overflow属性时Material UI奇怪的蓝线

标签 javascript reactjs google-chrome material-ui

我在我的 React 应用程序中使用 Material-UI。我也在使用样式化组件,并且在 Chrome 浏览器中查看该应用程序。使用 Firefox 浏览器时不会出现我遇到的问题。

在我的样式组件中应用 overflow 属性时,我看到这条蓝线朝向模态底部。这仅在我调整浏览器窗口大小时出现。当我逐渐将浏览器窗口拉近正常大小时,这条线就消失了。我不确定这是为什么,也不知道我能做些什么来解决它。

这是我的代码片段:

export const ScrollableModal = styled(MUIModal)(() => ({
  overflow: 'scroll',
}));

const Modal = ({ title, children, actionsLeft, actionsRight, ...rest }) => {
  const wrappedTitle =
    typeof title === 'string' ? <Typography>{title}</Typography> : title;

  return (
    <ScrollableModal {...rest}>
      <Container>

我已将其余部分排除在外,因为它与我的问题无关。

这是我所描述内容的屏幕截图:

screenshot

最佳答案

我猜这就是他们在 documentation 中提到的 outline 属性对于简单模态:

Notice that you can disable the outline (often blue or gold) with the outline: 0 CSS property.

首先需要在当前样式中添加:

const useStyles = makeStyles({
  modal: {
    textAlign: 'center',
    width: '35vw',
    backgroundColor: 'white',
    opacity: 0.8,
    outline: 0, // add / remove
  }
});

然后它就可以应用在Container上,就像渲染中的下面这样:

const styles = useStyles();

return <>
  <Modal open={true}>
    <Container className={styles.modal}>
      <p>Simple Modal</p>
    </Container>
  </Modal>
</>

添加和删除值为 0outline 属性的结果:

modals

如果您不想为此目的使用 makeSTLyes,我想对于带样式的组件,只需创建一个带有 opacity: 0 的带样式的 Container .

这为我解决了问题。

希望对您有所帮助!

关于javascript - 添加overflow属性时Material UI奇怪的蓝线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59041574/

相关文章:

javascript - 为什么我应该选择在 AngularJS 中使用服务而不是工厂?

javascript - 使用 D3 (v5) 应用多个过渡

javascript - setState 对象列表中的多个值

google-chrome - Chrome 开发者工具缺少时间轴 View

css - Chrome : Text container not 100% height

javascript - 在没有 UI 的情况下 ionic 裁剪图像

javascript - 为什么我的 React getDOMNode().textContent javascript 字符串不等于字符串?

用于类似 Google 文档的文本评论的 CSS

javascript - Webkit 中的全局 Javascript 变量

javascript - 陷入 Codecademy 的 Javascript fizzbuzz 应用程序中