开发者

How to put Text over the Image in Sitecore?

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

I know this can be achieved开发者_Python百科 via CSS but in this case control cannot be configured as we cannot override inline styles.

Any hints?


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 {}


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;
  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜