- 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:

推薦閱讀
- 極簡算法史:從數學到機器的故事
- Objective-C Memory Management Essentials
- Hands-On Data Structures and Algorithms with JavaScript
- MySQL 8 DBA基礎教程
- Mastering RStudio:Develop,Communicate,and Collaborate with R
- Mastering JBoss Enterprise Application Platform 7
- 新一代SDN:VMware NSX 網絡原理與實踐
- Java語言程序設計教程
- Learning Modular Java Programming
- .NET Standard 2.0 Cookbook
- 零基礎學HTML+CSS第2版
- 計算語言學導論
- Python應用與實戰
- 產品架構評估原理與方法
- RESTful Web API Design with Node.js