I need to split the background of an html page in 2 (horizontally). The top and bottom part will have a different background image/texture, that will be repeated, in other words expandable with the window’s size.
On top of this “split background”, I want to display some content, like texts or images.
This code generates a “split background” like I want, but I can’t/don’t know how to put content on top of that…
<html>
<head>
<style type="text/css">
html{height: 100%;}
body { width: 100%; height: 100%; }
.top { width: 100%; height: 50%; background-image:url('img/top.jpg'); }
.bottom { width: 100%; height: 50%; background-image:url('img/bottom.jpg'); }
</style>
</head>
<body>
<div class="top"></div>
<div class="bottom"></div>
</body>
</html>
The content should be centered vertically and horiontally on top of this “split background”. I tried to use a third div, play with z-indexes and use the css3 multiple bg feature, but I couldn’t get the result wanted.
Any suggestions?
Ok at the end I couldn’t find a solution in CSS. The content image I was placing over the 2 other divs would not align correctly if the browser window was too small…
I solved it using some javascript, since the site I develop already contains Javascript, it wasn’t an issue.
Here is the html:
And the css: