Absolutely, it can be done.
Essentially, what I did was set the background image as the background for the <body>
element (although it doesn't have to be specifically the body), and then inserted the image inside with a slight margin.
<body>
<img id='fg' src='http://3.bp.blogspot.com/-OYlUbWqyqog/TeL-gXGx3MI/AAAAAAAAHRc/bdqvvvaeC7c/s1600/bald-eagle3.jpg'></img>
</body>
css:
body {
margin: 0; padding: 0;
overflow: hidden;
background: url('http://wallpaper.zoda.ru/bd/2006/07/21/2c7b4306fd22f049f331d43adb74a5f7.jpg') no-repeat left top;
}
#fg {
margin: 20px 20px;
opacity: 0.7;
}
If the window size is too large, there may be some issues. One approach could be using media queries to fetch different image sizes based on the window dimensions.
edit — If you wish for the image to crop and maintain the correct aspect ratio, knowing the image size beforehand could be crucial. Without that information, here's another alternative option.
<body>
<div id='fg'> </div>
</body>
css:
body {
margin: 0; padding: 0;
overflow: hidden;
background: url('http://wallpaper.zoda.ru/bd/2006/07/21/2c7b4306fd22f049f331d43adb74a5f7.jpg') no-repeat left top;
}
body, html { width: 100%; height: 100%; }
#fg {
margin: 2%; width: 96%; height: 96%;
opacity: 0.7;
background: url('http://3.bp.blogspot.com/-OYlUbWqyqog/TeL-gXGx3MI/AAAAAAAAHRc/bdqvvvaeC7c/s1600/bald-eagle3.jpg') no-repeat center center;
}
If you are aware of the image dimensions, setting max-height and max-width could be beneficial. (I will experiment with that as well :-)
another edit To ensure the background crops in a centered manner, adjusting the position to "center center" instead of "left top" might be necessary. (Or "center top" if horizontal centering is sufficient.)
Vertically centering elements using CSS without advanced non-standard features like flexbox is challenging. JavaScript might be required for such tasks. It's worth noting that utilizing JavaScript solutions can significantly slow down the browser. A possible workaround is introducing a slight delay before recalculations occur, ensuring CPU efficiency during window resizing events.
further update @Kent Brewster's suggestion for vertical centering is excellent - that trick always slips my mind :-)