Fluid faux columns without images. Source independent. The use of rgba background is only to show the area of each box. No problem putting links in the content ( #non ). The markup for this section looks like this: ---------------------- Supp2: Third in source ---------------------- Sed accumsan neque a nisi luctus volutpat. Quisque placerat nibh ac leo varius non varius lacus cursus. Curabitur bibendum volutpat eleifend. Nullam sit amet dolor massa. Nunc consectetur ornare purus, et euismod nunc cursus at. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec aliquet leo nec quam vestibulum non mattis odio dapibus. Curabitur consequat odio odio. Proin a justo at lorem ultricies hendrerit. Sed accumsan neque a nisi luctus volutpat. Quisque placerat nibh ac leo varius non varius lacus cursus. Curabitur bibendum volutpat eleifend. Nullam sit amet dolor massa. Nunc consectetur ornare purus, et euismod nunc cursus at. Vestibulum ante ipsum primis in faucibus orci. Dribbble style buttons without images ( http://dribbble.com ) This example uses one element and one image (a sprite). Using pseudo-elements for additional background-images lets you clip sprites and fake the positioning of a background image from any side (not just the top and left). [content] Images that break out of the box are a popular effect. This is easy to achieve with pseudo-elements. No need for images in the markup, nested elements, or empty elements. Depending on the look you're after you can absolutely position or float the pseudo-element. This technique gives you a lot of flexibility over the positioning of presentational imagery. They can be part of the normal flow; or content can flow around them (float); or they can be removed from the document flow entirely and positioned from any side (absolute/fixed positioning). This example floats the pseudo-element so the main content's text will wrap around this image. [content] [content] An element with the popular folded-corner effect (with CSS only), two background images, and a generated-content image. P.S. Don't let your designer friends see my comic sans [content] You can find me on twitter ( http://twitter.com/necolas ). Multiple Backgrounds and Borders with CSS 2.1. You'll have to view the CSS file because Firebug won't show pseudo-elements.Nicolas Gallagher
********************************* Multiple Backgrounds demo for Silverback ( http://silverbackapp.com/ )'s parallax effect with more gorillas. [content] --------------------- Main: First in source ---------------------
Fit for purpose
Resize your browser. How wide am I?
Only one element to reproduce
Silverback's parallax effect with more gorillas.
<div id="silverback">[content]</div>
A div
with at least one child element provides 7 "borders".
Popular two-colour border without images
Up to 7 single-side "borders" from one element. Actually, 8 if you are prepared to show some of the element's background colour as a fake border.
FABW's complex borders
Vivamus auctor, tellus vel dictum pulvinar, a congue elit odio vel enim. Quisque fringilla semper fermentum. Nulla a felis a diam dapibus accumsan.
Supp1: Second in source
Vivamus auctor, tellus vel dictum pulvinar, a congue elit odio vel enim. Quisque fringilla semper fermentum. Nulla a felis a diam dapibus accumsan. Etiam varius fringilla magna sit amet hendrerit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Supp2: Third in source
Sed accumsan neque a nisi luctus volutpat. Quisque placerat nibh ac leo varius non varius lacus cursus. Curabitur bibendum volutpat eleifend. Nullam sit amet dolor massa. Nunc consectetur ornare purus, et euismod nunc cursus at. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec aliquet leo nec quam vestibulum non mattis odio dapibus. Curabitur consequat odio odio. Proin a justo at lorem ultricies hendrerit.
Sed accumsan neque a nisi luctus volutpat. Quisque placerat nibh ac leo varius non varius lacus cursus. Curabitur bibendum volutpat eleifend. Nullam sit amet dolor massa. Nunc consectetur ornare purus, et euismod nunc cursus at. Vestibulum ante ipsum primis in faucibus orci.
This example uses one element and one image (a sprite).
Using pseudo-elements for additional background-images lets you clip sprites and fake the positioning of a background image from any side (not just the top and left).
<div id="sprite">[content]</div>
The background can even live outside the box
Images that break out of the box are a popular effect. This is easy to achieve with pseudo-elements. No need for images in the markup, nested elements, or empty elements.
Depending on the look you're after you can absolutely position or float the pseudo-element. This technique gives you a lot of flexibility over the positioning of presentational imagery. They can be part of the normal flow; or content can flow around them (float); or they can be removed from the document flow entirely and positioned from any side (absolute/fixed positioning).
This example floats the pseudo-element so the main content's text will wrap around this image.
<div id="outside"> <div class="hero">[content]</div> <div class="main">[content]</div> </div>
An element with the popular folded-corner effect (with CSS only), two background images, and a generated-content image.
P.S. Don't let your designer friends see my comic sans
<div id="corner">[content]</div>
Jquery for Designers uses nested div
's and 3 images on its About page to create this effect. Using pseudo-elements as background canvases, just one element is needed.
<div id="j4d">[content]</div>
http://nicolasgallagher.com/multiple-backgrounds-and-borders-with-css2/demo/v...
http://nicolasgallagher.com/multiple-backgrounds-and-borders-with-css2/demo/f... http://nicolasgallagher.com/multiple-backgrounds-and-borders-with-css2/demo/p... http://nicolasgallagher.com/multiple-backgrounds-and-borders-with-css2/demo/j..." border="0" />
Read the article: Multiple Backgrounds and Borders with CSS 2.1.
9th Jun 2010
About me
I'm a London-based freelance Front-End Web Developer, CSS researcher and hacker, co-creator of Normalize.css, and contributor to the HTML5 Boilerplate project.
The organisations I've done work for include ASOS, Central Office of Information, The Department of Health, Arthritis Research UK, Natural England, and UCL. Further information is available in my résumé.
This is my personal blog. I write here – usually on topics related to front-end development – as part of engaging with, and learning from, other developers.
nicolas@nicolasgallagher.com. Copyright © 2011 Nicolas Gallagher.
Original code is dual licensed under the MIT and GNU GPLv2 licenses.
Original photographs and text are licensed under a Creative Commons BY-SA license. Vivamus auctor, tellus vel dictum pulvinar, a congue elit odio vel enim. Quisque fringilla semper fermentum.
You can find me on twitter.
Multiple Backgrounds with CSS 2.1 Read the article: Multiple Backgrounds and Borders with CSS 2.1 . You can find me on twitter . Fluid faux columns without images. Source independent. The use of rgba background is only to show the area of each box. No problem putting links in the content ( #non ). T ...»
See Ya