【问题标题】:Material-ui ListItem style override @mediaMaterial-ui ListItem 样式覆盖@media
【发布时间】:2017-02-22 10:47:06
【问题描述】:

我需要在 material-ui 中更改ListItem 的样式。

我有我的元素列表,填写后我将返回到Popover

elms.push(<ListItem key={i} primaryText={obj[i].title} onTouchTap={this.addGeotag.bind(this, obj[i])}/>)

如果我只是将style={{line-height:"5"}} 添加到ListItem 一切正常。

但我需要使用@media max-width: ...。因为我在那里会有一些选择。前任。 850px, 1200px, ...

我怎样才能做到这一点?

【问题讨论】:

    标签: css material-ui


    【解决方案1】:

    这样的事情应该可以工作。

    componentDidMount() {
        window.addEventListener('resize', this.listenOnResize);
    },
    
    componentDidUnmount() {
        window.removeEventListener('resize', this.listenOnResize);
    },
    
    listenOnResize(event) {
        // Do calculations here
        // Save in state what size prop you want for your component
    },
    

    【讨论】:

      猜你喜欢
      • 2020-01-30
      • 2019-03-07
      • 2020-05-27
      • 2020-08-10
      • 2021-06-30
      • 1970-01-01
      • 2020-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多