The Grid Layout spec will soon change your approach to website design, but there will still be plenty of uses for CSS positioning tricks. Whether you want to create sidebars that remain in the viewport (browser window), add sticky section headings to lists or long articles, or overlap one element with another, this concise ebook will expertly guide you through all the main CSS positioning types.
Short and deep, this book is an excerpt from the upcoming fourth edition of CSS: The Definitive Guide. When you purchase either the print or the ebook edition of Positioning in CSS, you’ll receive a discount on the entire Definitive Guide once it’s released. Why wait? Make your web pages come alive today.
You'll learn how to:
Remove an element from a document but keep its new position part of the document’s flow with absolute positioning
Keep an element like a masthead or sidebar in one fixed position in the viewport with fixed positioning
Preserve an element’s shape and the space it occupied in the document with relative positioning
Make a document’s headers selectively stay still in response to scrolling conditions with sticky positioning
Eric A. Meyer is an author, speaker, blogger, sometime teacher, and co-founder of An Event Apart. He’s a two-decade veteran of the Web and web standards, a past member of the W3C’s Cascading Style Sheets Working Group, and the author of O’Reilly’s CSS: The Definitive Guide.
Eric A. Meyer is the author of the critically acclaimed online tutorial Introduction to HTML, as well as some other semi-popular Web pages. He is a member of the CSS&FP Working Group and the author of Cascading Style Sheets: The Definitive Guide.
The animals on the cover of Positioning in CSS are salmon (salmonidae), which is a family of fish consisting of many different species. Two of the most common salmon are the Pacific salmon and the Atlantic salmon.
Pacific salmon live in the northern Pacific Ocean off the coasts of North America and Asia. There are five subspecies of Pacific salmon, with an average weight of 10 to 30 pounds. Pacific salmon are born in the fall in freshwater stream gravel beds, where they incubate through the winter and emerge as inch-long fish. They live for a year or two in streams or lakes and then head downstream to the ocean. There they live for a few years, before heading back upstream to their exact place of birth to spawn and then die.
Atlantic salmon live in the northern Atlantic Ocean off the coasts of North America and Europe. There are many subspecies of Atlantic salmon, including the trout and the char. Their average weight is 10 to 20 pounds. The Atlantic salmon family has a life cycle similar to that of its Pacific cousins, and also travels from freshwater gravel beds to the sea. A major difference between the two, however, is that the Atlantic salmon does not die after spawning; it can return to the ocean and then return to the stream to spawn again, usually two or three times.
Salmon, in general, are graceful, silver-colored fish with spots on their backs and fins. Their diet consists of plankton, insect larvae, shrimp, and smaller fish. Their unusually keen sense of smell is thought to help them navigate from the ocean back to the exact spot of their birth, upstream past many obstacles. Some species of salmon remain landlocked, living their entire lives in freshwater.
Salmon are an important part of the ecosystem, as their decaying bodies provide fertilizer for streambeds. Their numbers have been dwindling over the years, however. Factors in the declining salmon population include habitat destruction, fishing, dams that block spawning paths, acid rain, droughts, floods, and pollution.
Many of the animals on O'Reilly covers are endangered; all of them are important to the world. To learn more about how you can help, go to animals.oreilly.com.
The cover image is a 19th-century engraving from the Dover Pictorial Archive. The cover fonts are URW Typewriter and Guardian Sans. The text font is Adobe Minion Pro; the heading font is Adobe Myriad Condensed; and the code font is Dalton Maag’s Ubuntu Mono.