【发布时间】:2018-04-26 14:48:32
【问题描述】:
我希望能够在达到给定屏幕尺寸时更改布局,这样我就可以更改网站在移动视图时的外观。
目前我的反应站点使用包Horitzontal Scroll Package水平滚动
我尝试使用 react-responsive 包来实现这一点,它允许我运行媒体查询,但两个包之间似乎存在冲突。
所以我希望我的网站在全屏(桌面和表格)时水平滚动,然后在移动视图中从上到下滚动。我该怎么做?
class Home extends React.Component{
constructor(props) {
super(props);
this.state = {};
}
componentWillMount() {
this.setState({
home: projectsData.filter( p => p.name === "homepage" ),
galleryImages: [
ImgOne,
ImgTwo,
ImgThree,
ImgFour,
ImgFive,
ImgSix
]
});
}
render(){
const test = { color: "black", position: "fixed" }
return(
<div className="row">
<Responsive minWidth={992}>
<HorizontalScroll reverseScroll={true}>
<Header />
<SplashScreen />
<CopyText />
</HorizontalScroll>
</Responsive>
</div>
);
}
}
注意:我知道水平滚动包不支持使用百分比调整大小。
【问题讨论】:
-
也许你可以在 componentDidMount 中做一些工作,就像这些答案一样:stackoverflow.com/questions/19014250/…
标签: javascript reactjs responsive-design