• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 499
  • Last Modified:

Stretching the baclground image in panel

Hello experts,

I am using a panel whose background image is set. Though I dont want the background image to get tiled but it should stretch inside the panel. How much ever small the image is, it should get stretched and fit to panel according to the size of panel.

How do I get this functionality??

Please note that there is a specific reason that I want to stretch the panel background image and I cannot use any <img> tag.

Please do let me know the suggestions.

Thanks

Regards,
Baz
0
baz86
Asked:
baz86
1 Solution
 
Ramkisan JagtapLead DeveloperCommented:
I think, the image will need to be of the correct width. You can't get a css background image to stretch to fit a panel. The only other way is to have an image <img> sitting inside the DIV, but with a lower z-index than everything else. It's somewhat of a hack.

Please check following link :

http://www.vbforums.com/showthread.php?t=538438

Regards,
Ram
0
 
hehdaddyCommented:
This is probably what @ramkisan was saying, but you can easily do this using CSS.

Instead of using a CSS background image, use a standard IMG, and set its class properties to something like this:

#img.source-image {
      width: 100%;
        height: 100%;
      position: absolute;
      top: 0;
      left: 0;
}

Height will only work if all the parents up the chain have height set to 100%.

Another alternative is to use jQuery and a jQuery plugin that will do it for you. I saw a few in the jQuery plugins directory at the site. http://www.jquery.com
0
 
baz86Author Commented:
Actually there is a specific reason because of which I cannot use  tag inside the panel. It has to be the background image of the panel.
So isnt there any way by which I can change stretch the background image?

Hope there is. :(

Thanks

Baz
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Ramkisan JagtapLead DeveloperCommented:
@Baz : Can you please share that reason? If possible we can give you aa another solution.

Regards,
Ram
0
 
baz86Author Commented:
Ok
I am creating a map for several countries for which I need a blank map template of that country so that I can label cities on that blank template.(Label cities means creating labels at run time of cities and displaying it on the template.)

I also have a functionality of image panning wherein user can drag the image in a parent panel.(all this is inside a parent panel.)

So if I place a image tag inside the panel(child) to be my blank map template..labels would be visible on the image. But when I move(drag) the image, only image would move and city labels wouldnt because labels are actually placed on panel(child) and not on image. As far as I know, we cant place labels on the image(control on control) can we?

So that is the reason if I set background image of the panel to that of empty map template then even the labels along with the template can be dragged. (since panel is a container and can hold controls like labels).So that background should fit(stretch according) to the size of panel otherwise city labels are moved.
And I cant even keep the size of image equal to size of the panel(manually using some photo editor) because there are various levels of zooming so I cant have those me pictures of different sizes.(and that too for each country! :(.....nah..)

Hopefully I have not confused you all.

Do let me know if you havent understood any part of whtever I wrote and also if there is any alternative to my problem.

Thanks.

Baz
0
 
Ramkisan JagtapLead DeveloperCommented:
Hi Baz,
You can use Image mapping concept in this situation.
Please try for it. If I got somthing I will definitely Inform you.

Regards,
Ram
0
 
baz86Author Commented:
Can you elaborate on wht is image mapping concept?

Is there any way by which I can make Image(tag) act as a container so that it can hold labels?

Regards,
0
 
Ramkisan JagtapLead DeveloperCommented:
Have you Checked above links?
You can use following features.
Hot spots features
There is no limit on number of hotspots each image may contain.
Each hotspot is characterized by various attributes like shape, location and size.
Overlapping hotspots are perfectly valid.
Hot spots are defined using x and y coordinates.
Hot spots can be assigned Image URL's and are capable of postback.

Different types of hot spots
There are three different types of hot spots offered by ImageMap control. They are:
CircleHotspot
RectangleHotspot
PolygonHotspot

0
 
baz86Author Commented:
@Ramkisan: Oh oks. Thanks for your suggestion. I ll go through and let you knw. Thanks.
0
 
baz86Author Commented:
Just found out that in any case you cant place text or labels on those hot spots. Imagemap control(i think) only defines the clickable regions on the imagemap, isnt it?
0
 
raaziqCommented:
if u r using image mapping u can only use tooltips for the hotspots instead of placing labels on it. anyway try ur luck.
0
 
baz86Author Commented:
@ raaziq: i am cant use image maps since i cannot add text on the map or on the hotspots. Along with tooltip even text should be visible. Thanks for ur suggestion.

0
 
baz86Author Commented:
Hello experts,

Since there was no other way by which I could find a way to stretch the background image of the panel, I used an external photo editor and manually increased dimensions of the background image. I know this is not a feasible solution in all cases but as a last resort I decided to go for this in my case.

@Ramkisan:- Thank you for all the comments

Regards,
Baz
0
 
baz86Author Commented:
This was the last but best possible solution I could think for my case. Though this may not be the ideal solution in all the cases.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now