At this point we've already looked at CSS fundamentals, how to style text, and how to style and manipulate the boxes that your content sits inside. Now it's time to look at how to place your boxes in the right place in relation to the viewport, and one another. We have covered the necessary prerequisites so we can now dive deep into CSS layout, looking at different display settings, traditional layout methods involving float and positioning, and modern layout tools like flexbox.
Before starting this module, you should already:
- Have basic familiarity with HTML, as discussed in the Introduction to HTML module.
- Be comfortable with CSS fundamentals, as discussed in Introduction to CSS.
- Understand how to style boxes.
Note: If you are working on a computer/tablet/other device where you don't have the ability to create your own files, you could try out (most of) the code examples in an online coding program such as JSBin or Thimble.
These articles will provide instruction on the fundamental layout tools and techniques available in CSS.
- Introduction to CSS layout
- This article will recap some of the CSS layout features we've already touched upon in previous modules — such as different
displayvalues — and introduce some of the concepts we'll be covering throughout this module.
- Originally for floating images inside blocks of text, the
floatproperty has become one of the most commonly used tools for creating multiple column layouts on webpages. This article explains all.
- Positioning allows you to take elements out of the normal document layout flow, and make them behave differently, for example sitting on top of one another, or always remaining in the same place inside the browser viewport. This article explains the different
positionvalues, and how to use them.
- Practical positioning examples
- With the basics of positioning covered in the last article, we will now look at building a couple of real world examples, to illustrate what kinds of things you can do with positioning.
- A new technology, but with support now fairly widespread across browsers, Flexbox is starting to become ready for widespread use. Flexbox provides tools to allow rapid creation of complex, flexible layouts, and features that historically proved difficult with CSS. This articles explains all the fundamentals.
- Grid systems are another very common feature used in CSS layouts, which tend to be implemented using floats or other layout features. You imagine your layout as a set number of columns (e.g. 4, 6, or 12), and then fit your content columns inside these imaginary columns. In this article we'll explore the basic idea behind creating a grid system, look at using a ready-made grid system provided by a grid framework, and end by experimenting with CSS Grids — a nascent new browser feature that makes implementing grid design on the Web a lot easier.