- Cross-platform Desktop Application Development:Electron,Node,NW.js,and React
- Dmitry Sheiko
- 134字
- 2021-07-15 17:36:25
Sticking the title bar and header
The layout looks fine without any content, but what happens to the layout if it receives content that is too long?

In fact, we will have a header and footer shifting out of the view when scrolling. It doesn't look user-friendly. Fortunately, we can change it easily using another fresh addition to CSS called Sticky positioning (https://www.w3.org/TR/css-position-3/#sticky-pos).
All we need to do is to modify slightly the title bar component:
./assets/css/Component/titlebar.css
.titlebar {
...
position: sticky;
top: 0;
}
and the footer:
./assets/css/Component/footer.css
.footer {
...
position: sticky;
bottom: 0;
}
In the preceding code, we declared that the title bar will stick to the top and footer to the bottom. Run the application now, and you will note that both boxes are always visible, regardless of scrolling:

推薦閱讀
- JavaScript從入門到精通(微視頻精編版)
- R語言數據可視化實戰
- TypeScript實戰指南
- 差分進化算法及其高維多目標優化應用
- Eclipse Plug-in Development:Beginner's Guide(Second Edition)
- JS全書:JavaScript Web前端開發指南
- HTML5入門經典
- 低代碼平臺開發實踐:基于React
- Corona SDK Mobile Game Development:Beginner's Guide(Second Edition)
- Windows Embedded CE 6.0程序設計實戰
- Buildbox 2.x Game Development
- 寫給程序員的Python教程
- Node.js從入門到精通
- H5+移動營銷設計寶典
- 編程的原則:改善代碼質量的101個方法