Tutorials on positioning elements with CSS
Elements can flow in-line or as blocks. They can be positioned relative, absolute or static. Margins and padding set on each element also affect the layout but the way these are respected can differ for different browsers and types of element. Floated blocks move left or right and can push non floated blocks out the way. Float clears push blocks down. stopping them from moving. The way floated blocks and non-floated block and in-line elments interact together and respect each other's padding and margins differs between browsers causing one of the biggest CSS headaches.
- Inline / block formatting
-
Webdesignfromscratch.com - block & inline
An overview of how and where HTML elements can be displayed either in block or inline style.
-
Communitymx.com - Block Formatting
Control Block Formatting Context - a block formatting context is as an isolated container that controls the layout of the boxes within it without regard for elements outside of it. For instance, when you float a div, it establishes a new block formatting context.
-
W3.org - Visual formatting model
A in depth overview of the inline formatting model. Note: A replaced element is a defined element (e.g. img) which is just a 'reserved' space for something else (e.g. img is replaced by scr="..."). Not for lovers of plain english.
-
Brunildo.org - Inline Block Layout
{display: inline-block} is a means to trigger hasLayout (in IE5.5+/Win), exactly as zoom: any_value. Elements having display:inline work like the standard inline-blocks: they flow horizontally, are sensitive to vertical-align, and apply shrink-wrapping to their contents.
-
Satzansatz.de - On Having Layout
Fixing many of Internet Explorer's rendering inconsistencies by giving an element 'layout' - how elements draw and bound their content or interact with other elements. Plus how IE/Win violates the CSS specification due to the presence or absence of layout on elements in the page.
-
Gunlaug.no - Investigating hasLayout
An overview of HasLayout vs. Overflow: hidden/auto for IE. This page shows one way to use W3C standards to accomodate standard compliant browsers - as we should, and hacks to fix a buggy and flawed IE/win - because we have to.
-
Microshaft.com - On Having Layout
Microsoft's explanation of havingLayout and those elements IE recognizes.
- css box model
-
Hicksdesign.co.uk - Box model explained
A 3D example of the box model as a helpful illustration.
-
BrainJar.com - CSS Positioning
An overview of the box model and how to position text on a page.
- css float and clearing
-
Maxdesign.com - Floatutorial
Step by step CSS float tutorial taking you through the basics of floating elements such as images, buttons, image galleries, inline lists and multi-column layouts.
-
Webreference.com - CSS Floats
A simple look at float basics.
-
Positioniseverything.net - Clearing floats
How to clear floats without structural mark-up.
-
Ejeliot.com - Float Containing Rules By Browser
A table demonstrating which rules cause a container to clear its floats in each of the main browsers.
-
Quirksmode.org - Easy clearing
A loats' container doesn't stretch up to accomodate the floats. You have to command the browsers to stretch up the container all the way.
-
Smashingmagazine.com - CSS float theory
The most important things you should keep in mind developing css-based layouts with floats.
- css positioning
-
Barelyfitz.com - CSS positioning
Learn CSS Positioning in Ten Steps - This tutorial examines the different layout properties available in CSS: position:static, position:relative, position:absolute, and float.
-
Stopdesign.com - Making the Absolute, Relative
Understanding the basics of nesting an absolute-positioned element within a relative-positioned element or visa-versa.
-
Mezzoblue.com - Variable height with minimum cross-browser fix
A lesson on producing cross-browser content with a minimum height box which can extend past that minimum height.
-
Intensivstation.ch - Horiz + Vert Centering
Centering an area both vertically and horizontally within the browser window. D-graff.de has another method of entering an area both vertically and horizontally within the browser window which works in IE Mac.
-
D-graff.de - Horiz + Vert Centering
Centering an area both vertically and horizontally within the browser window which works in IE Mac. Intensivstation.ch 's Horiz + Vert Centering is a simpler version (which doesn't).
-
Css-discuss.org - Overlapping & z-index
There's three different things that impact how elements overlap each other: stacking contexts, source order, and painting order.
- positioning images
-
Clagnut.com - Positioning images
Understanding how three images with fixed dimensions can be positioned along side each other.
- Pmob.co.uk - Center Elements of no WidthTrevor Davis's Why is there no float: center? covers centering images between two columns of text.
-
Cssplay.co.uk - Centered image
Centering an image of unknown size in an outer container of known size.
-
Ghettocooler.net - Non wrapped floats
Floating an image in a block of content without the content wrapping around the image.
-
Brunildo.org - CSS gallery layout
Works in IE5+ Win & Mac, Op7+, Saf (using inline-block), Moz (using -moz-inline-box). Variable size images inside fixed width (yellow) containers flowing (in a horizontally centered way) inside a (gray) fluid container.
- fixed positioning
-
Howtocreate.co.uk - I.E. 5.5+ fixed position
Making fixed position elements fixed in IE 5.5+. Uses expressions for IE hacks in conditional comments to fix elements.
-
Gunlaug.no - IE-expressions
Using dual mode IE-expression to have fixed positioning of elements across browsers.
-
Annevankesteren.nl - IE fixed position
Emulating fixed positioning and top: 0 or bottom: 0 in IE.
-
Ryanfait.com - sticky footer
An explanation for sticking the footer to bottom of browser viewing area.