80 likes | 208 Vues
In this lecture, we explore how to design a flexible three-column layout using CSS. The layout features two fixed side columns and a flexible center column that adjusts as the browser window resizes, while ensuring that the footer remains at the bottom of the page. We discuss four possible layout scenarios based on the size relationships between the content and side columns. The lecture culminates in a practical HTML and CSS implementation, detailing how to structure the boxes correctly and apply styles to create an engaging web design.
E N D
Technologies for web publishing Ing. Václav Freylich Lecture 6
Content • CSS layouts • Flexible three column layout aTNPW1-6
Header Menu Main content box Submenu,voting, news, … Footer What is the idea? We want to create the layout with two fixed side columns and one fexible column in the centre. When resize the window the content box size is changed. The header and footer width is changed. The side boxes aren’t changed aTNPW1-6
Four possible situations 1) 2) 3) 4) aTNPW1-6
Four possible situations 1) and 2) One of the sidebars is longer than the content box 3) Content box is longer than sidebars 4) Content box is shorter than sidebars In all described situations we need to keep the footer at the bottom! aTNPW1-6
1 2 4 3 5 Solution - the floating boxes • Mark the boxes with numbers (numbers are the order of boxes in HTML code) • The order of the boxes 2 – 4 – 3 is important ! • Boxes 2 and 3 are floating ! aTNPW1-6
HTML code Put the boxes into the HTML code according their order <div id=“layout”> <div id=“header”>Header text</div> <div id=“menu”>Menu items</div> <div id=“right”>Voting, news, …</div> <div id=“content”>Main content</div> <div id=“footer”>Footer content</div> </div> aTNPW1-6
CSS style Create the CSS style definitions #header { width: 100%; height: 50px; background-color: blue;} #menu { width: 150px; height: 350px; background-color: red; float: left; } #right { width: 150px; height: 250px; background-color: yellow; float: right; } #content {color: red;} #footer {clear: both; background-color: green;} aTNPW1-6