Website Preview with Live Overrides
Overrides allow you to perform non-destructive, real-time CSS changes for nearly any website. You don't need any access to the server beyond the ability to browse it as a normal user. This offers boundless potential for experimenting and discovering how other websites tick.
Topics
Getting Started
First, open a new preview with Preview ⟩ New Preview Tab (control command P) and enter the address you wish to preview. If you already have a copy of the CSS, open it in Espresso. This can either be a standard CSS file or a SCSS/LESS style sheet in a Dynamo folder.
- In the toolbar, click the Edit button. It lists the page's style sheets, and marks the ones that can be overridden.
- Choose the style sheet you want to override. You can also turn on Xray, click an element, and click one of its rules in the Xray panel.
- Espresso asks whether you want to override the style sheet with a local one. Choose Extract the contents into a new style sheet if you do not have a copy, or Use an existing style sheet and pick yours, then click Override and Edit.
- Play with colors and styling: have fun.
The original style sheet on the server is not modified.
Editing Style Sheets
Once you have an Override set up, any changes you make in the overriding document will be reflected in your preview, as you edit. (When the override is a SCSS or LESS style sheet, the preview follows each time Dynamo builds it, which is when you save.) After you are happy with how the CSS looks, you can upload the file to your server so that everyone else will see the same changes when they load your site.
As always, Xray is extremely useful to navigate styles applied to page elements, and with a stylesheet in front, the CSS tools in the inspector change its rules for you.
The override comment
Espresso inserts a comment at the top of the overriding style sheet that looks like this:
/* @override
http://example.com/path/to/style.css */
This comment is what cues Espresso in that you want to use a CSS override for this stylesheet, so if you save the comment with your file, any previews for that website will automatically turn into live previews when you open the stylesheet in the future (and since it is a comment, it will not affect users in normal browsers if you leave it in when you upload your stylesheet to the server).
The comment must be the first thing in the file. It can name more than one address, each on its own line, if the same style sheet is served from several.
If the style sheet's address ends in a query, such as style.css?v=42, Espresso asks whether to use a wildcard. With Use Wildcard the address is written as style.css?*, and the override goes on working when the number changes.
A style sheet that is brought in by another with @import can only be overridden together with the one that imports it. Espresso tells you so, and offers to override that one too.
Troubleshooting
Some CSS properties may not work as expected. In particular, if you are linking to an image in your stylesheet (a background image, for instance), the image will need to be relative to the server copy of the stylesheet, not your local copy. This means you need to upload any new images prior to them showing up in your preview.