#Overlay
This javascript function enables one font to be added on top of another.
Some fonts are designed to be used together, such as Acier Bat Display Outline and Acier Bat Display Strokes. This script enables people to specify a font to overlay using the :after pseudo class.
##Requirements
- Requires Javascript, but degrades gracefully using the
has-overlay
class - Works in IE9, Firefox 3+, Safari and Chrome
- Doesn't support target elements which contain other HTML elements (eg
<strong>
,<br>
)
##Usage
- Include overlay.js at the bottom of your document, just before the closing
</html>
tag. - Call the function
setOverlay()
, passing in a string containing the CSS selectors you wish to style (egsetOverlay('h1, h2, .acier');
). - In your CSS, specify the font as you wish for it to appear in browsers which don't support this technique (eg
h1 { ... }
) - Override the styles using the
.has-overlay
selector (eg.has-overlay h1 { ... }
) - Specify the font to use for the overlay using the
:after
psudo class (egh1:after { ... }
)
##Example
If you want to see this technique in practice, launch example.html
in a browser. Fonts are set up to work on the domains localhost
and overlay.dev
.
##Troubleshooting
Firefox can be quite sensitive to the font's metrics when using the CSS property font-size-adjust
. If the fonts are not lining up properly in Firefox, try removing this property.