I have a large image iI want to set as background for a div. But the image is rather large. Here it is:
https://i.stack.imgur.com/vaupg.png
On ther right hand side it will contain text.
How would I go about doing this without having to load such a large image with css?
If you want to add plain text on top of the image you can just use positioning to place a child element in the correct place:
HTMl —
CSS —
Here is a demo: http://jsfiddle.net/XhJZW/
Update
You’re image is pretty simple, you can re-create it with CSS gradients like this:
HTML —
CSS —
Here is a demo: http://jsfiddle.net/XhJZW/3/
The above CSS is approximately 2KB. About a quarter of the PNG image.
Note that browsers will render the gradients and the
border-radiusdifferently depending on what the browser supports. The oldest browsers will just see a couple of grey boxes on top of each other (no rounded corners and no gradients).