【问题标题】:Custom modal background diming in react反应中的自定义模态背景变暗
【发布时间】:2020-10-08 12:02:34
【问题描述】:

我有以下代码。请帮助我如何在模式打开时添加不透明度或如何使背景变暗。

这里是working example

【问题讨论】:

    标签: css reactjs bootstrap-modal opacity


    【解决方案1】:

    将此backgroundColor 属性添加到您的Modal 组件中的第57 行:

    style={{
      display: this.state.display,
      backgroundColor: this.state.modalShow ? "red" : "none"
    }}
    

    这样做的作用是,当modalShow 状态为真时(也就是显示时),backgroundColor 以另一种方式返回 rednone。要使其变暗,您显然可以使用rgba(0,0,0,.2) 而不是red

    编辑:sandbox

    【讨论】:

    • 这是我要实现的东西点击launch demo modal就可以看到效果getbootstrap.com/docs/4.0/components/modal
    • 是的,这就是我刚刚回答的问题。你有问题吗?我正在编辑共享我的代码框
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-18
    • 1970-01-01
    • 1970-01-01
    • 2020-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多