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

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:

主站蜘蛛池模板: 安陆市| 静乐县| 永修县| 南宁市| 德清县| 云林县| 西城区| 巴东县| 沙田区| 高青县| 阳原县| 京山县| 泸州市| 甘孜| 邵阳县| 黄梅县| 海伦市| 射洪县| 博爱县| 凤城市| 平和县| 阜城县| 黄梅县| 连平县| 长武县| 绍兴市| 杭锦旗| 驻马店市| 千阳县| 新丰县| 白水县| 巩义市| 长岛县| 太康县| 沛县| 平阳县| 泰安市| 塔河县| 博客| 城市| 揭阳市|