Skip to main content
sumit5290
October 16, 2015
Respondido

How add Image as background

  • October 16, 2015
  • 3 respostas
  • 3942 Visualizações

In the complex component, how to make the image as background image and the text as center align on the background image??

Este tópico foi fechado para respostas.
Melhor resposta por Lokesh_Shivalingaiah

It should be taken care in your CSS making image as background and text as center aligned for that div

3 Respostas

Level 8
October 16, 2015

The image object has a getSrc() property.  You can switch your code up to utilize it:

<%

    Image image = new Image(resource, "image");

    image.setSelector(".img");

    String text = properties.get("text", "TEXT NA");


%>

    <%= text %>

<div style="background-image: url(<%=image.getSrc() %>);"></div>

sumit5290
October 16, 2015

bsloki wrote...

It should be taken care in your CSS making image as background and text as center aligned for that div

 

<%@include file="/libs/foundation/global.jsp"%>
<%@ page import="com.day.cq.wcm.foundation.Image" %>
<%

    Image image = new Image(resource, "image");

    image.setSelector(".img");

    String text = properties.get("text", "TEXT NA");


%>

    <%= text %>
<%
    image.draw(out);

%>
<%
   image.getDescription().length();
%>

 

 

i m using this code...how to have the css inside it

Lokesh_Shivalingaiah
Level 10
October 16, 2015

It should be taken care in your CSS making image as background and text as center aligned for that div