2017-05-24 46 views

回答

1

您可以使用媒体查询:

@media only screen and (max-width : 480px) { 
    .yourClass { width: 100%; } 
} 
+0

它给出了内联样式,并且没有在prop中使用类名。我想出了解决方案并发布了它。我们需要使用bodyStyle道具。 –

3

嗯,我想通了,只需要传递{宽度:“100%”}在bodyStyle道具,它从它覆盖。

+1

对我很好!谢谢! –

+0

订阅的Github问题可以在https://github.com/angular/material2/issues/1951找到。这似乎不适用于使用'openFromComponent'打开的小吃店,并且它似乎在使用“open” – mtpultz

0

宽度不适用于我,因为它没有影响不知道为什么。虽然我设置为100%,但宽度仅取默认值。我能够使用minWidth应用全宽,并且我正在使用material-ui版本:0.18.7。您必须重写minWidth值以应用自定义宽度。请在下面找到示例

import Snackbar from 'material-ui/Snackbar'; 

const bodyStyle = { 
    border: `2px solid ${config.actualWhite}`, 
    height:55, 
    minWidth: 1385, 
    background: config.snackbarColor, 
    fontFamily: config.fontFamily, 
    fontStyle: config.fontStyle, 
    fontWeight: config.fontWeight, 
    fontSize: config.fontSize, 
    borderBottomRightRadius: 46, 
    borderBottomLeftRadius: 46 
} 

<Snackbar 
     open={this.state.open} 
     message={this.state.error} 
     autoHideDuration={4000} 
     bodyStyle={bodyStyle} 
     action="Close" 
     onRequestClose={this.handleRequestClose} 
     onActionTouchTap={this.handleRequestClose} 
     style={myTheme.snackbarfromTop} 
     />