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

Chapter 3. Fluid Layouts and Responsive Images

Eons ago, in the mists of time (well the late 1990s), websites were typically built with their widths defined as percentages. These percentage-based widths fluidly adjusted to the screen viewing them and became known as fluid layouts.

In the years shortly after, in the mid to late 2000s, there was an intervening fixation on fixed width designs (I blame those pesky print designers and their obsession with pixel perfect precision). Nowadays, as we build responsive web designs we need to look back to fluid layouts and remember all the benefits they offer.

In Chapter 2, Media Queries – Supporting Differing Viewports, we ultimately conceded that while media queries allowed our design to adapt to changing viewport sizes, by snapping from one set of styles to another, we needed some ability to flex our design between the 'break points' that media queries provided. By coding a 'fluid' layout, we can facilitate this need perfectly; it will effortlessly stretch to fill the gaps between our media query break points.

In 2015, we have better means to build responsive web sites than ever. There is a new CSS layout module called Flexible Box (or Flexbox as it is more commonly known) that now has enough browser support to make it viable for everyday use.

It can do more than merely provide a fluid layout mechanism. Want to be able to easily center content, change the source order of markup, and generally create amazing layouts with relevant ease? Flexbox is the layout mechanism for you. The majority of this chapter deals with Flexbox, covering all the incredible capabilities it has to offer.

There is another key area to responsive web design we can address better now than ever before and that's responsive images. There are now specified methods and syntax for sending devices the most relevant version of an image for their viewport. We will spend the last section of this chapter understanding how responsive images work and how we can make them work for us.

In this chapter we will cover:

  • How to convert fixed pixel sizes to proportional sizes
  • Consider existing CSS layout mechanisms and their shortfalls
  • Understand the Flexible Box Layout Module and the benefits it offers
  • Learn the correct syntax for resolution switching and art direction with responsive images
主站蜘蛛池模板: 涿州市| 平定县| 长沙市| 郸城县| 同仁县| 日土县| 武隆县| 南漳县| 新化县| 台安县| 子长县| 庄浪县| 大田县| 巴南区| 华宁县| 高平市| 象州县| 岫岩| 东乡县| 金阳县| 阿瓦提县| 麻城市| 陆丰市| 天柱县| 昌乐县| 易门县| 东兴市| 呼图壁县| 泊头市| 苍南县| 婺源县| 宁德市| 潮州市| 罗山县| 邵阳市| 九龙县| 汝南县| 农安县| 阿克| 赣榆县| 本溪市|