You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by measwel <ma...@yahoo.com.au> on 2009/09/02 07:05:06 UTC

How to specifiy a background image in a tile?

LS,

How can I specify a background image inside a tile element? For instance, I
have a template like this:

    <table cellpadding="0" cellspacing="0" width="100%" border="1">
      <tr>
        <td align="right" colspan="2"><tiles:insertAttribute
name="header"/></td>
      </tr>
      <tr>
        <td width="200px"><tiles:insertAttribute name='sidebar'/></td>
        <td>
          <table>
            <tr><td><tiles:insertAttribute name='body'/></td></tr>
            <tr><td><tiles:insertAttribute name='footer'/></td></tr>
          </table>
        </td>
      </tr>
    </table>

Now I would like the sidebar tile to have a specific background image. How
can I accomplish this?

Thank you,
MPK

-- 
View this message in context: http://www.nabble.com/How-to-specifiy-a-background-image-in-a-tile--tp25251708p25251708.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: How to specifiy a background image in a tile?

Posted by Luke Scholefield <lj...@me.com>.
You could also specify the background image using the style attribute  
in the table tag:

<table style="background-image: url(img.jpg)" >

This would let you specify it by page, where as just using an external  
style sheet would not.

<table style="background-image: url(<tiles:insertAttribute  
name='backgroundimg'/>)" >

Of course, if you are only specifying single image (or even a few, use  
different styles), it would  be better to do it as a style sheet.  If  
it does change that much, it would seem more appropriate to use it as  
a JSP/JSTL tag.

Not sure if this is poor form in terms of coding standards, but it  
should work.

On 02/09/2009, at 10:47 PM, Griffith, Michael * wrote:

> Create a style in your CSS that has a background image:
>
> sidebar {
> 	margin: 0;
> 	padding: 0;
> 	background-image: url(../images/background.png);
> }
>
> then assign the css style to the div using the class attribute:
>
> <div class="sidebar">
> 	<table...>
> </div>
>
>
> -----Original Message-----
> From: measwel [mailto:marek_karczewski@yahoo.com.au]
> Sent: Wednesday, September 02, 2009 8:08 AM
> To: users@tiles.apache.org
> Subject: Re: How to specifiy a background image in a tile?
>
>
> Maybe it would be better to do it with a stylesheet? What would you
> choose?
> If so, how can it be done ?
> --
> View this message in context:
> http://www.nabble.com/How-to-specifiy-a-background-image-in-a-tile--tp25
> 251708p25257150.html
> Sent from the tiles users mailing list archive at Nabble.com.
>


RE: How to specifiy a background image in a tile?

Posted by "Griffith, Michael *" <Mi...@fda.hhs.gov>.
Create a style in your CSS that has a background image:

sidebar {
	margin: 0;
	padding: 0;
	background-image: url(../images/background.png);
}

then assign the css style to the div using the class attribute:

<div class="sidebar">
	<table...>
</div>
 

-----Original Message-----
From: measwel [mailto:marek_karczewski@yahoo.com.au] 
Sent: Wednesday, September 02, 2009 8:08 AM
To: users@tiles.apache.org
Subject: Re: How to specifiy a background image in a tile?


Maybe it would be better to do it with a stylesheet? What would you
choose?
If so, how can it be done ?
--
View this message in context:
http://www.nabble.com/How-to-specifiy-a-background-image-in-a-tile--tp25
251708p25257150.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: How to specifiy a background image in a tile?

Posted by Antonio Petrelli <an...@gmail.com>.
2009/9/2 measwel <ma...@yahoo.com.au>:
>
> Maybe it would be better to do it with a stylesheet? What would you choose?
> If so, how can it be done ?

Oh right, not simply "image" but "background image". CSS is the best
choice. But in this case Tiles won't help, because it is not needed.
Or am I missing something?

Antonio

Re: How to specifiy a background image in a tile?

Posted by measwel <ma...@yahoo.com.au>.
Maybe it would be better to do it with a stylesheet? What would you choose?
If so, how can it be done ?
-- 
View this message in context: http://www.nabble.com/How-to-specifiy-a-background-image-in-a-tile--tp25251708p25257150.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: How to specifiy a background image in a tile?

Posted by Antonio Petrelli <an...@gmail.com>.
2009/9/2 measwel <ma...@yahoo.com.au>:
>        <td width="200px"><tiles:insertAttribute name='sidebar'/></td>
> ...
> Now I would like the sidebar tile to have a specific background image. How
> can I accomplish this?

Put a definition as the "sidebar" attribute. The template of this
definition should contain something like this:

<tiles:importAttribute name="sidebarBackground" />
...
<img src="${sidebarBackground}" />

HTH
Antonio