【发布时间】:2017-10-24 15:05:45
【问题描述】:
小吃栏在移动屏幕中不会占据 100% 的宽度。任何人都可以帮助在小屏幕的情况下如何仍然给出 100% 的宽度?
-> 在这次提交之前,width:'auto' 成功了,但现在不行了。
感谢任何帮助。
【问题讨论】:
标签: css reactjs material-ui snackbar
小吃栏在移动屏幕中不会占据 100% 的宽度。任何人都可以帮助在小屏幕的情况下如何仍然给出 100% 的宽度?
-> 在这次提交之前,width:'auto' 成功了,但现在不行了。
感谢任何帮助。
【问题讨论】:
标签: css reactjs material-ui snackbar
宽度对我不起作用,因为它不知道为什么。尽管我设置为 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}
/>
【讨论】:
我想通了,只需要在 bodyStyle 属性中传入 {width: '100%'},它会覆盖它。
【讨论】:
openFromComponent 打开的小吃店,并且似乎仅使用open 时可能已修复
您可以使用媒体查询:
@media only screen and (max-width : 480px) {
.yourClass { width: 100%; }
}
【讨论】: