Help with setting background property on a div

22 views
Skip to first unread message

John Gentilin

unread,
Jan 24, 2012, 3:27:41 PM1/24/12
to gwtquery
I have an HTMLPanel that is an Element of a UIBinder template.
Using the following code, I am trying to set the background image but
it
doesn't work

String burl = "url('" + m_Images.get(currentImage).getUrl() + "')
no-repeat;";
// First try with the HTMLPanel Widget
GQuery gslider = $(slider);
gslider.css("background", burl);

// Then try with just a selector, neither work
gslider = $(".slider");
gslider.css("background", burl);

where burl resolves to
url('http://test.picrollr.com:8888/web/img/slider/default1.jpg') no-
repeat;

and gslider is in the variable inspector
<div style="height: 500px;" class="slider"></div>

Now if I add this line to the the code
gslider.css("color", "#C0C0C0");

It works to set the color attribute, and the gslider now resolves to
<div style="height: 500px; color: rgb(192, 192, 192);"
class="slider"></div>

Any ideas ?

Thank You
John Gentilin

Julien Dramaix

unread,
Feb 8, 2012, 10:26:10 AM2/8/12
to gwtq...@googlegroups.com
the background shorthand property must be specified like that :
background: color image repeat position;
e.g. : background: transparentno-repeat left top;

In your case you only specify background-image and backgroung-repeat...

Try something like that :

String burl = "url('" + m_Images.get(currentImage).getUrl() + "')";

GQuery gslider = $(slider);
gslider.css("background-repeat", "no-repeat");
gslider.css("background-image", burl);

julien

> --
> You received this message because you are subscribed to the Google Groups "gwtquery" group.
> To post to this group, send email to gwtq...@googlegroups.com.
> To unsubscribe from this group, send email to gwtquery+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/gwtquery?hl=en.
>

Reply all
Reply to author
Forward
0 new messages