Note that there are some explanatory texts on larger screens.

plurals
  1. POLayer text over an image?
    primarykey
    data
    text
    <p>I am trying to lay text over an image. I set the z-index on the div, but that doesn't do anything until I set the position to absolute.</p> <pre><code>&lt;script&gt; function SwitchActiveDiv() { $("#SummaryDiv").css('display', 'none'); $("#DetailsDiv").css('display', 'inline'); } function SwapOpenImage(img) { var ToImage = $(img).attr('src').substring($(img).attr('src').lastIndexOf('/')); ToImage = ToImage.replace('closed', 'open'); var FromImage = $("#OpenImage").attr('src').substring($(img).attr('src').lastIndexOf('/')); FromImage = FromImage.replace('open', 'closed'); var OpenImageSrc = $("#OpenImage").attr('src'); OpenImageSrc = OpenImageSrc.substring(0, OpenImageSrc.lastIndexOf('/')) + ToImage; var CloseImageSrc = $(img).attr('src'); CloseImageSrc = CloseImageSrc.substring(0, CloseImageSrc.lastIndexOf('/')) + FromImage; $("#OpenImage").attr('src', OpenImageSrc); $(img).attr('src', CloseImageSrc); } &lt;/script&gt; &lt;div id="SummaryDiv" style="width: 100%;"&gt; &lt;table&gt; &lt;tr&gt; &lt;td style="width: 712px;"&gt; &lt;img src="~/media/C2MAssets/GettingStartedIntro/change-image.jpg" alt="" onclick="javascript:SwitchActiveDiv();" /&gt; &lt;/td&gt; &lt;td style="padding-left: 3px;"&gt; &lt;img src="~/media/C2MAssets/GettingStartedIntro/family-image.jpg" alt="" onclick="javascript:SwitchActiveDiv();" /&gt; &lt;/td&gt; &lt;td style="padding-left: 3px;"&gt; &lt;img src="~/media/C2MAssets/GettingStartedIntro/lifestyle-image.jpg" alt="" onclick="javascript:SwitchActiveDiv();" /&gt; &lt;/td&gt; &lt;td style="padding-left: 3px;"&gt; &lt;img src="~/media/C2MAssets/GettingStartedIntro/play-image.jpg" alt="" onclick="javascript:SwitchActiveDiv();" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;&lt;/div&gt; &lt;div id="DetailsDiv" style="width: 100%; display: none;"&gt; &lt;table&gt; &lt;tr&gt; &lt;td rowspan="3"&gt; &lt;img id="OpenImage" src="~/media/C2MAssets/GettingStartedDetails/change-open.jpg" alt="" /&gt; &lt;div style="z-index: 20; left: 800px; top: 330px; position: relative;"&gt; &lt;p style="font-family: Helvetica Neue; font-size: 35px; font-weight: bold; color: #ffffff;"&gt;Ready for an&lt;br/&gt; &lt;i&gt;Upgrade?&lt;/i&gt;&lt;/p&gt; &lt;/div&gt; &lt;/td&gt; &lt;td cellpadding="0" cellspacing="0"&gt; &lt;img id="ClosedImage1" src="~/media/C2MAssets/GettingStartedDetails/family-closed.jpg" alt="" onclick="javascript:SwapOpenImage(this);" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;img id="ClosedImage2" src="~/media/C2MAssets/GettingStartedDetails/lifestyle-closed.jpg" alt="" onclick="javascript:SwapOpenImage(this);" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;img id="ClosedImage3" src="~/media/C2MAssets/GettingStartedDetails/play-closed.jpg" alt="" onclick="javascript:SwapOpenImage(this);" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;&lt;/div&gt; </code></pre> <p>Then when I set the position, it sort of works. Initially, the top div is not visible and then jquery enables it. When the top div is enambled, the text div is still not visible and doesn't become visible until some jquery is activated to replace the image that the text should be over, then it becomes visible.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload