tags:

views:

62

answers:

2

I need to create user control where <sc:text/> element should showed over the <sc:image>.

I know this can be achieved via CSS but in this case control cannot be configured as we cannot override inline styles.

Any hints?

A: 

You can achieve this using the sc:fld extension function and wrapping sc:text in markup, adding class names or ids (or inline styles if you must!).

<img src="{sc:fld( 'graphic', $sc_currentitem, 'src’ )}" class="head" />
<span class="txt"><sc:text field="txtField" /></span>

You can then style these as normal

img.head {}
span.txt {}
adam
A: 

I don't understand the problem. This seems like more of a front-end problem than a Sitecore issue. CSS will work fine. Here's a rough example (not tested but gets you the idea):

Sample HTML:

<div class="my-container">
  <div class="img">
    <sc:image Field="Bar" runat="server" />
  </div>
  <div class="txt">
    <sc:text Field="Foo" runat="server" />
  </div>
</div>

Sample CSS:

.my-container {
  position: relative;
}

  .my-container .txt {
    position: absolute;
    z-index: 50;
    top: 0px;
  }

  .my-container .img {
    z-index: 10;
  }
Mark Ursino
Should this CSS put in the user control source? Can it be overrode in hosted page?
DixonD
You can put it where you want. In the control is fine.
Mark Ursino