【发布时间】:2017-03-23 17:53:52
【问题描述】:
我制作了一个粘性页脚高级组件,它将其他组件包装在自身内部:
Footer.js
//this is a higher-order component that wraps other components placing them in footer
var style = {
backgroundColor: "#F8F8F8",
borderTop: "1px solid #E7E7E7",
textAlign: "center",
padding: "20px",
position: "fixed",
left: "0",
bottom: "0",
height: "60px",
width: "100%",
};
const Footer = React.createClass({
render: function() {
return (
<div style={style}>
{this.props.children}
</div>
);
}
});
export default Footer;
用法:
<Footer><Button>test</Button></Footer>
但它隐藏了页面的内容:
这似乎是一个常见的问题,所以我搜索了一下,找到了this issue,其中 FlexBox 推荐用于粘性页脚。但是在this demo,页脚位于页面的最底部,而我需要页脚始终显示在页面上并且内容在上述区域内滚动(如SO chat)。除此之外,还有是使用自定义样式表规则更改所有其他组件的建议。是否可以仅使用页脚组件样式来实现我需要的功能,以便代码保持模块化?
【问题讨论】:
标签: css reactjs footer react-jsx jsx