Cascading Style Sheets (CSS) is the basic aesthetic language of the web. You can now gain full control over your invoice design with our new CSS editor. Here we will look at a range of techniques for applying specific styles, controlling positioning, dimensions, and colour themes.
Advanced health warning: CSS is not a subject that can be grasped in five minutes, and will require some degree of patience. If you are not confident or simply haven’t got the time, you can hire any reasonably competent web developer to help you build your style. This guide is by no means exhaustive and will serve only as an overview of the basic concepts.
Now go to any invoice preview screen and in the top left you should see a green button “Invoice style gallery”. If you don’t see the button you’re probably on the old template. You can update the template in the Sales menu, under “Invoice customisation”. If you’re on the old template you will see a big red box with an option to upgrade, and you’ll need to do this before you can proceed further.
When you click the above button you’ll then see a range of pre-configured invoice styles. You can click on any of these styles and your invoice preview will instantly update. To access the CSS editor you will need to click the orange button above the selected style saying “Customise this style”.
.invoice-header-region {
width: 630px;
height: 350px;
...
...
}
The name “invoice-header-region” relates to the class name and will be referenced in the invoice markup. To see the markup and find the various classes you need to edit you will need to switch on the developer tools in your browser. For Chrome and Firefox browsers press F12 and a panel will pop open at the foot of the screen where you can peer into the page markup, or as my colleague calls it “The Matrix”.
As you run your cursor over the elements in the markup they will light up on the screen. Look specifically at the class name for each element (highlighted in yellow), and you should then be able to find this class in the editor window so that you know exactly what you’re modifying. Avoid modifying any classes outside the parent “nested-invoice container” as this will affect the user interface rather than the actual invoice.
Another trick you can use to find a class name in Google Chrome is to right click on your screen at the position of the element and select the option “Inspect element” in the context menu. This will open the developer tools panel and highlight the exact class you’re interested in, or near enough (you may need to look around the highlighted area).
OK, that’s about all we will cover on the basics. Experimentation is always the best way to learn, so have a play around with the editor. Don’t worry you won’t break anything, and you can always go back to one of the default styles. There are also some excellent online resources that will delve deeper into the world of CSS.
Some elements will have a property “position: absolute;”. This tells the element to position in a very strict position based on an x and y coordinate. For example open the “Standard” template and pop open the CSS editor. Locate the following style:
The styles we are interested in are highlighted in yellow. The styles “left” and “top” act as your x and y axis, change these values and apply the style to see the labels box move around. “Top” defines the number of pixels from the top of the container element, “left” is the number of pixels from the left edge, you can also use “right” and “bottom” for similar effect.
If an element is not set with “position:absolute;” then it will flow with the rest of the content in the container, left to right, top to bottom.
Borders are a useful way to see what you’re editing but they may also form part of your desired style. Here (again on the Standard template) I have added a 1 pixel red border around the recipient address. By manipulating these variables I can increase the thickness, change the colour, I can even make the border dashed or dotted by using these words in place of solid.
There are a few different ways of expressing colour in CSS, using the name of the colour or entering the hex code. Both examples are displayed above. The hex code will give you a far bigger palette, there’s a great online colour picker you can use here to get the exact colour you need.
*Note: Don’t forget to use the American spelling for colour (color) in your CSS.
Be careful when dimensioning and positioning elements. If the elements contain text like the above example you want to avoid that text flowing over other elements on the page.
In the example below we’ve used a 20px padding-left in order to push the text away from the right border:
Try not to stretch your logo beyond its original size as this will result in some unwanted pixelation. In addition, work to retain the original aspect ratio. You will retain the original aspect ratio by setting only the “width” or only the “height”, not both (as in my bad example above). It’s also worth noting here that if you append the attribute “!important;” this tells the editor to override any other style definition and treat this one as the most important. In most cases you won’t need to use this but if your styles aren’t having any effect, try adding it.
You can completely hide some elements of the invoice. To achieve this use the property “display: none;”.
If you want to change the basic text of the invoice then look for the class “.invoice-text.” Remember to stick to web-safe fonts, otherwise your clients may be looking at something different to what you see.
For any overlaps first decide whether it is the element invading the space or the element that is getting eclipsed that is at fault. For the former you may want to modify the size of the offending element, for the latter it may be a case of moving its position so it’s clear of the overlap.
You may also conclude that professional help is needed to get the exact look you’re after. As mentioned previously CSS is a universal language and any decent web developer should be able to traverse this subject with ease, saving you a lot of stress in the long run as accounting can be enough of a headache without additional things to worry about.
In some cases you may want to overwrite the default labels within the invoice template, things like “Invoice No”, “Due Date”, “Issue Date” etc. A particular use-case might be when you want to customise the template with your own language. For this we can use CSS transform classes. These are custom classes that allow you to swap out the text in labels with your own. If this is something you’re looking to do then please take a look at the following guide.