how to overwrite the content of an html tag with other content dynamically and keep the size

I have some html content, e.g. a div. Now I want to overwrite the content dynamically with other content, e.g. fill it with a color or a pattern. I can use javascript (actually I am using angular). The size and the position of the div should be kept.