Reputation: 347
We have two div
s. divOne
contains information of image and divTwo
contains information of table. Is it possible that we can set divOne as background image of divTwo
using script?
divOne.innerHTML = <IMG src="http://sbc.com/xyz.jpg" />
divTwo.innerHTML = <TABLE id="content"> ....... </TABLE>
Upvotes: 0
Views: 920
Reputation: 2980
divOne.style.backgroundImage="url(http://sbc.com/xyz.jpg);";
That should set divOne to that background image...
For the div Positioning give this a try...
divOne.style.position = "relative";
divOne.style.top = "0px";
divOne.style.left = "0px";
divOne.style.zIndex="1";
divTwo.style.position = "relative";
divTwo.style.top = "0px";
divTwo.style.left = "0px";
divTwo.style.zIndex="2";
Upvotes: 0
Reputation: 14123
Yes - depending on what you mean.
You can position one DIV over another using relative positions and z-index. If the top index is transparent (no background) then you should be able to see through to the one behind it.
Upvotes: 1