官术网_书友最值得收藏!

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:

主站蜘蛛池模板: 瑞金市| 诸暨市| 荥经县| 吐鲁番市| 镇远县| 两当县| 正宁县| 石台县| 新津县| 和硕县| 莱西市| 若尔盖县| 达拉特旗| 嵊州市| 池州市| 连城县| 莒南县| 三都| 疏附县| 沁水县| 石河子市| 定日县| 永寿县| 和静县| 宜宾市| 大田县| 鄂州市| 会昌县| 泰顺县| 巴林左旗| 韶关市| 长寿区| 库车县| 张家川| 行唐县| 西丰县| 随州市| 和平区| 远安县| 奇台县| 宁国市|