HTML CSS examples for CSS Layout:Relative Position
Alternating left and right positioning with CSS
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> #wrap {<!-- w ww .ja v a2s. c o m--> position:relative; } #wrap div { width:201px; height:201px; margin:11px; background:blue; } #wrap div:nth-child(even) { float:right; clear:right; } #wrap div:nth-child(odd) { float:left; clear:left; } </style> </head> <body> <div id="wrap"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> </body> </html>